Oh,

Just to help you debug how log4j is configuring itself, add the
following to the logging.properties file

log4j.debug=true
log4j.rootLogger=DEBUG, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender

Log4j will simply print out "how it is configuring itself" on the console

On 9/19/07, Karan Malhi <[EMAIL PROTECTED]> wrote:
> Dain,
>
> My guess is that you might have already figured out the below and I
> might be missing something here. However, just want to jot down the
> behaviour of the Logger, maybe you might find some easier option than
> the hack ;)
>
> logging.properties does not refer to a ${openejb.home} or
> ${openejb.base}. So, I am not sure how you are replacing it and
> getting it to work. Maybe I am missing something.
>
> Basically logging.properties has the following:
>
> log4j.appender.R.File=logs/openejb.log
> log4j.appender.TX.File=logs/transaction.log
>
> One thing which the Logger does is to look for a system property
> called openejb.logger.external . If it finds this property to be true,
> it does not use the logger.properties file found in openejb-core.jar
> and instead leaves it upto  the external entity (tomcat in this case)
> to configure logging.
>
> So, what tomcat could do is
> 1. set the openejb.logger.external property to true
> 2. find the logging.properties file from openejb-core.jar
> 3. load the logging.properties file into a properties object
> 4. replace the log4j.appender.R.File  and log4j.appender.TX.File
> property value to ${wherever tomcat wants the log file}
> 5. Use PropertyConfigurator.configure(the properties object);
>
> OpenEjb Logger will simply obey to your commands.
>
> Here is the code (in Logger) which takes care of "obeying the commands
> of the external entity"
>
>         static {
>                 try {
>                         String prop = 
> System.getProperty("openejb.logger.external","false");
>                         boolean externalLogging = Boolean.parseBoolean(prop);
>                         if(!externalLogging)
>                                 configureInternal();
>                 } catch (IOException e) {
>
>
>                 }
>         }
>
> The second option could be that we could simply update the
> logger.properties file to contain the following:
>
> log4j.appender.R.File=${openejb.home}/logs/openejb.log
> log4j.appender.TX.File=${openejb.home}/logs/transaction.log
>
> This way tomcat just needs to set the openejb.home property properly,
> and leave everything upto the Logger to configure itself and write to
> the files in the correct directory. Tomcat does not need to set the
> openejb.logger.external to true in this case.
>
> Maybe there might be an even easier way, but the above are the two
> options springing in my mind right now. Let me know if the above
> works/doesnt work.
>
>
>
>
>
> On 9/18/07, Dain Sundstrom <[EMAIL PROTECTED]> wrote:
> > On Sep 18, 2007, at 7:31 PM, [EMAIL PROTECTED] wrote:
> >
> > > +    private static void preprocessProperties(Properties props) {
> > > +        String openejbHome = SystemInstance.get().getHome
> > > ().getDirectory().getAbsolutePath();
> > > +        String openejbBase = SystemInstance.get().getBase
> > > ().getDirectory().getAbsolutePath();
> > > +        for (Map.Entry<Object, Object> entry : props.entrySet()) {
> > > +            String value = (String) entry.getValue();
> > > +            value = value.replace("${openejb.home}", openejbHome);
> > > +            value = value.replace("${openejb.base}", openejbBase);
> > > +            entry.setValue(value);
> > > +        }
> > > +    }
> >
> > I ran into a strange problem in the Tomcat integration... the log
> > files were appearing in ${user.dir}/logs instead of the server logs
> > dir.  I couldn't think of an easy way around the problem, so I hacked
> > the above method into the Logger class.  Basically, it replaces $
> > {openejb.home} and ${openejb.base} in the logging.properties file
> > with their respective values.  Is there some standard way we
> > accomplish this?  If so, I can remove this hack.  Otherwise it we can
> > leave it :)
> >
> > -dain
> >
>
>
> --
> Karan Singh Malhi
>


-- 
Karan Singh Malhi

Reply via email to