You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by J IK <ji...@yahoo.com> on 2002/09/09 20:01:20 UTC

multiple categories same config file

Hi All:

Following is my configuration file log4j.config:

log4j.rootCategory=WARN, Log2Console

log4j.appender.Log2Console=org.apache.log4j.ConsoleAppender
log4j.appender.Log2Console.Target=System.err
log4j.appender.Log2Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Log2Console.layout.ConversionPattern=[%d{dd MMM
yyyy HH:mm:ss}]%c-%-5p: %m%n

# Main component's properties
log4j.category.a=DEBUG, aa
log4j.category.b=DEBUG, bb

# SyncServer properties
log4j.appender.aa=org.apache.log4j.RollingFileAppender
log4j.appender.aa.File=aa.log
log4j.appender.aa.MaxFileSize=1KB
log4j.appender.aa.MaxBackupIndex=10
log4j.appender.aa.layout=org.apache.log4j.PatternLayout
log4j.appender.aa.layout.ConversionPattern=[%d{dd MMM yyyy
HH:mm:ss}]%c-%-5p: %m%n

# Admin properties
log4j.appender.bb=org.apache.log4j.RollingFileAppender
log4j.appender.bb.File=bb.log
log4j.appender.bb.MaxFileSize=1KB
log4j.appender.bb.MaxBackupIndex=10
log4j.appender.bb.layout=org.apache.log4j.PatternLayout
log4j.appender.bb.layout.ConversionPattern=[%d{dd MMM yyyy
HH:mm:ss}]%c-%-5p: %m%n

Now log4j is opening both the files aa.log and bb.log when i
just instantiate the 'aa' appender in a JVM. This is locking the
file 'bb.log' which is used by another application in a
different JVM. This is causing rollover problems etc.

I can eliminate the problem by using two different log4j config
files and by listing different appender properties in those two
but I want to avoid that and use a single config file for ease
of maintenance. Please let me know if/how I can do that.

Thanks in advance.

Regards,
-Jik

__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: multiple categories same config file

Posted by Ceki Gülcü <ce...@qos.ch>.
At 14:03 09.09.2002 -0700, you wrote:
>Two JVMs here are NOT using the same log file to log into, all
>I'm using is the same log4j config file. Each application
>initializes the log4j in its own JVM and uses its own category.
>
>The problem seems to be that the log4j is opening all the
>category files which appear in the config file and not
>apparently releasing the not-needed ones.

Log4j does not know they are not needed.


--
Ceki

TCP implementations will follow a general principle of robustness: be
conservative in what you do, be liberal in what you accept from
others. -- Jon Postel, RFC 793



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: multiple categories same config file

Posted by J IK <ji...@yahoo.com>.
Two JVMs here are NOT using the same log file to log into, all
I'm using is the same log4j config file. Each application
initializes the log4j in its own JVM and uses its own category. 

The problem seems to be that the log4j is opening all the
category files which appear in the config file and not
apparently releasing the not-needed ones.

Thank you.
-Jik

--- Ceki G�lc� <ce...@qos.ch> wrote:
> At 11:01 09.09.2002 -0700, you wrote:
> >Hi All:
> >
> >
> >Now log4j is opening both the files aa.log and bb.log when i
> >just instantiate the 'aa' appender in a JVM. This is locking
> the
> >file 'bb.log' which is used by another application in a
> >different JVM. This is causing rollover problems etc.
> 
> You can't have two JVMs access the same system resource (e.g.
> a file). You 
> have two options:
> 
> 1) Use different files
> 
> 2) Write an appender to use the JDK 1.4 NIO package.
> 
> 
> --
> Ceki
> 
> TCP implementations will follow a general principle of
> robustness: be
> conservative in what you do, be liberal in what you accept
> from
> others. -- Jon Postel, RFC 793
> 
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: multiple categories same config file

Posted by Ceki Gülcü <ce...@qos.ch>.
At 11:01 09.09.2002 -0700, you wrote:
>Hi All:
>
>
>Now log4j is opening both the files aa.log and bb.log when i
>just instantiate the 'aa' appender in a JVM. This is locking the
>file 'bb.log' which is used by another application in a
>different JVM. This is causing rollover problems etc.

You can't have two JVMs access the same system resource (e.g. a file). You 
have two options:

1) Use different files

2) Write an appender to use the JDK 1.4 NIO package.


--
Ceki

TCP implementations will follow a general principle of robustness: be
conservative in what you do, be liberal in what you accept from
others. -- Jon Postel, RFC 793



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>