[logback-user] JoranConfigurator

Ceki Gulcu ceki at qos.ch
Wed Mar 18 22:39:09 CET 2009


Hello Greg,

I have not looked at log4j 1.3 code for a long time. Here is some code
that will probably do what you want:

   // code for log4j 1.3 and not logback
   logger = org.apache.log4j.Logger.getLogger(className);
   JoranConfigurator jc = new JoranConfigurator();
   jc.doConfigure(configFile, LogManager.getLoggerRepository());
   ExecutionContext ec =  jc.getExecutionContext();
   for(Object o: ec.getErrorList()) {
     System.out.println(o);
   }

Again the above code is for log4j 1.3 not logback.

HTH,

Greg Flex wrote:
> Hi Ceki Gülcü,
> 
> Thanks for your fast reply.
> So the problem is that I'm not using the Logback but the Log4j 1.3 alpha 
> 8 version that also has
> JoranConfigurator object.  (author: Curt Arnold, Ceki Gülcü 
> <http://www.qos.ch/log4j/>)
> I thought I ask you since you've written it and you more likely to reply 
> to my message from this forum.
> I'm looking at the (Log4j 1.3 alpha 8) API and don't see any 
> LoggerContext object there.
> I have at the moment this in my class:
> 
> public someConstructor(String className, String propertyFile) {
>       
>         //Reads the configuration file.
>         if (!configFile.endsWith("xml") || configFile == ""){
>             throw new InvalidParameterException("Invalid XML property 
> file.");
>         }
>      
>         logger = org.apache.log4j.Logger.getLogger(className);
>         JoranConfigurator jc = new JoranConfigurator();
>         jc.doConfigure(configFile, LogManager.getLoggerRepository());
>     }
> 
-- 
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch


More information about the Logback-user mailing list