Change default Log4J logger tapestry

2012-10-09 Thread djst
Hi there.

Do any of you know how I can specify which Log4J logger tapestry should use?

You see, I'm trying to set Log4J up so I have two separate log files. One
containing the internal tapestry log entries and one containing my own
specified log entries. Here is my properties file:

og4j.rootLogger=INFO,console, tapestryLog

#Console appender
log4j.appender.console = org.apache.log4j.ConsoleAppender
log4j.appender.console.layout = org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern = %t %-5p %c{2} - %m%n

#TapestryAppender
log4j.appender.tapestryLog=org.apache.log4j.FileAppender
log4j.appender.tapestryLog.layout=org.apache.log4j.PatternLayout
log4j.appender.tapestryLog.layout.ConversionPattern=%-22d{dd-MM-
HH:mm:ss} %-8p %c [%t] - %m (%l)%n
log4j.appender.tapestryLog.File=C:/tapestrylog.log
log4j.appender.tapestryLog.threshold=INFO

#CustomAppender
log4j.logger.myLogger=INFO,myLog

log4j.appender.myLog=org.apache.log4j.FileAppender
log4j.appender.myLog.layout=org.apache.log4j.PatternLayout
log4j.appender.myLog.layout.ConversionPattern=%-22d{dd-MM- HH:mm:ss}
%-8p %c [%t] - %m (%l)%n
log4j.appender.myLog.File=C:/myLog.log
log4j.appender.myLog.threshold=INFO

As you can see, I have two loggers (i.e. rootLogger and myLogger). The
rootLogger has the tapestryLog  fileappender which logs to
c:\tapestryLog.log and the myLogger has the appLog fileappender which logs
to c:\myLog.log. 

In my code I then access each logger as follows:

Logger logger = LoggerFactory.getLogger(myLogger); //Log to myLog.log
Logger logger = LoggerFactory.getLogger(ClassName.class); //Log to
tapestryLog.log

The problem is that even though, in my java code, I only log a statement to
appLogger, it gets logged to the rootLogger as well. On the other hand when
I log something to tapestryLog is does not get logged to appLog.log. Since
everything gets logged to the rootLogger I would like to change it so
tapestry uses another logger than the rootLogger. 


Thanks in advance!

Best, 
David



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Change-default-Log4J-logger-tapestry-tp5716725.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Change default Log4J logger tapestry

2012-10-09 Thread Josh Canfield
I believe this is your problem.

http://veerasundar.com/blog/2009/08/log4j-tutorial-additivity-what-and-why/

Josh

On Tue, Oct 9, 2012 at 4:21 AM, djst da...@ctu.dk wrote:

 Hi there.

 Do any of you know how I can specify which Log4J logger tapestry should
 use?

 You see, I'm trying to set Log4J up so I have two separate log files. One
 containing the internal tapestry log entries and one containing my own
 specified log entries. Here is my properties file:

 og4j.rootLogger=INFO,console, tapestryLog

 #Console appender
 log4j.appender.console = org.apache.log4j.ConsoleAppender
 log4j.appender.console.layout = org.apache.log4j.PatternLayout
 log4j.appender.console.layout.ConversionPattern = %t %-5p %c{2} - %m%n

 #TapestryAppender
 log4j.appender.tapestryLog=org.apache.log4j.FileAppender
 log4j.appender.tapestryLog.layout=org.apache.log4j.PatternLayout
 log4j.appender.tapestryLog.layout.ConversionPattern=%-22d{dd-MM-
 HH:mm:ss} %-8p %c [%t] - %m (%l)%n
 log4j.appender.tapestryLog.File=C:/tapestrylog.log
 log4j.appender.tapestryLog.threshold=INFO

 #CustomAppender
 log4j.logger.myLogger=INFO,myLog

 log4j.appender.myLog=org.apache.log4j.FileAppender
 log4j.appender.myLog.layout=org.apache.log4j.PatternLayout
 log4j.appender.myLog.layout.ConversionPattern=%-22d{dd-MM- HH:mm:ss}
 %-8p %c [%t] - %m (%l)%n
 log4j.appender.myLog.File=C:/myLog.log
 log4j.appender.myLog.threshold=INFO

 As you can see, I have two loggers (i.e. rootLogger and myLogger). The
 rootLogger has the tapestryLog  fileappender which logs to
 c:\tapestryLog.log and the myLogger has the appLog fileappender which logs
 to c:\myLog.log.

 In my code I then access each logger as follows:

 Logger logger = LoggerFactory.getLogger(myLogger); //Log to myLog.log
 Logger logger = LoggerFactory.getLogger(ClassName.class); //Log to
 tapestryLog.log

 The problem is that even though, in my java code, I only log a statement to
 appLogger, it gets logged to the rootLogger as well. On the other hand when
 I log something to tapestryLog is does not get logged to appLog.log. Since
 everything gets logged to the rootLogger I would like to change it so
 tapestry uses another logger than the rootLogger.


 Thanks in advance!

 Best,
 David



 --
 View this message in context:
 http://tapestry.1045711.n5.nabble.com/Change-default-Log4J-logger-tapestry-tp5716725.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org