[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [xmlblaster-devel] Redirect LogChannel for log4j



Hi Uwe,

right now I'm just at the same propblem as you have been a few month ago.

Do I understand you right, that you add these two methods to your
xmlBlaster-specific Class to catch all log-calls which come from
XmlBlasterconnection and so.

Or do you have a much more sohisticated way which I'm not seeing right now
;-)

kind regards

Heinrich

On Mon, 29 Jul 2002, Uwe Renzland wrote:

>Hi Marcel,
>
>I saw, that the changes are not so easy, because not all possible
>LogChannels
>are known within the Global Object in the moment, I want
>to initialize my logging. They are inserted dynamically when
>they are used.
>
>So I did not make any changes within the famous xmlBlaster and
>initializes
>my logging in the following way (this is not a good solution, but it
>considers
>all known log ids, more I do not need):
>
>  /**
>   * add 'this' to all known LogChannels
>   * so this.log() will be triggerd for all xmlBlaster specific logs.
>   * So we have a chance, to log xmlBlaster stuff into our logfile.
>   */
>  private void initXmlBlasterLogging()
>  {
>    if (xmlBlasterLoggingInitialized)
>      return;
>    xmlBlasterLoggingInitialized = true;
>    glob.getLog("core").addLogDevice(this);
>    glob.getLog("auth").addLogDevice(this);
>    glob.getLog("cb").addLogDevice(this);
>    glob.getLog("mime").addLogDevice(this);
>    glob.getLog("corba").addLogDevice(this);
>    glob.getLog("xmlrpc").addLogDevice(this);
>    glob.getLog("admin").addLogDevice(this);
>  }
>
>
>Uwe
>
>Marcel wrote
>>
>> Bom diaz Uwe,
>>
>> >Hi xmlBlaster Developer,
>> >
>> >I am developing a application that uses Log4J.
>> >The xmlBlaster client classes are used in this project.
>> >
>> >Now xml Blaster has its own logging. I would like, that the xmlblaster
>> >loggings would appear in my log4j files.
>> >The xmlBlaster (jutils) LogChannel has a super feature. I can define a
>> >
>> Honour to Juergen Birkle ...
>>
>> >callback Interface, so all log calls can be caught and manipulated, e.g.
>> >like this:
>> >
>> >public class c implements  org.jutils.log.LogableDevice {
>> >    /**
>> >    * Event fired by LogChannel.java through interface LogableDevice.
>> >    * <p />
>> >    * Log output into our Category <br />
>> >    */
>> >   public void log(int level, String source, String str)
>> >   {
>> >     final Category log =
>> >org.apache.log4j.Category.getInstance("org.xmlblaster");
>> >
>> >     StringBuffer logTxt = new StringBuffer();
>> >     logTxt.append("[");
>> >     logTxt.append(source);
>> >     logTxt.append("] ");
>> >     logTxt.append(str);
>> >     switch (level) {
>> >     case LogChannel.LOG_CALL:
>> >     case LogChannel.LOG_DUMP:
>> >     case LogChannel.LOG_TIME:
>> >     case LogChannel.LOG_TRACE:
>> >       if (log.isDebugEnabled())
>> >        log.debug(logTxt);
>> >       break;
>> >     case LogChannel.LOG_ERROR:
>> >       log.error(logTxt);
>> >       break;
>> >     case LogChannel.LOG_INFO:
>> >       log.info(logTxt);
>> >       break;
>> >     case LogChannel.LOG_WARN:
>> >       log.warn(logTxt);
>> >       break;
>> >     default:
>> >       log.info(logTxt);
>> >       break;
>> >     };
>> >   }
>> >}
>> >
>> Cool!
>>
>> >
>> >Now I have a problem with initializing. I have to get all LogChannels,
>> >that are used by Global, without knowing the ids.
>> >But there exists no appropriate method.
>> >If I would have it, e.g. Enumeration Global.getLogs(), I could
>> >initialize all Channels by adding my Interceptor.
>> >
>> >Perhaps you can add it.
>> >
>> Please just add it yourself and commit it to xmlBlaster.org
>>
>> thanks,
>>
>> Marcel
>>
>> >
>> >Thank you and many greetings
>> >
>> >Uwe