Guess .-1 is not 100% correct It was asked to send all log events to a file
#the rootLogger logs warning, errors and fatal, and it's only appender is named A1 log4j.rootLogger=WARN, A1 # A1 is a FileAppender log4j.appender.A1=org.apache.log4j.FileAppender # A1's file-path is output/temp # - the file is stored at directory "output" with name "temp" and has no extension log4j.appender.A1.file=output/temp # A1 loggs warnings, errors and fatals, this just in case someone would adjust later the lootLogger #If the rootLoggers level would be debug, A1 would still only log warnings errors and fatals #but if you want to controll that all using the rootLogger's level property then just commet this out log4j.appender.A1.threshold=WARN # we define that we intend to use a Pattern to configure log-record-layouts log4j.appender.A1.layout=org.apache.log4j.PatternLayout # AND the actual pattern to configured the layout of each log event is "%-5p - %m%n" file.log4j.appender.A1.layout.ConversionPattern=%-5p - %m%n and go for this link to see what each pattern-chars semantic is. http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html Josef -----Ursprüngliche Nachricht----- Von: Douglas E Wegscheid [mailto:[email protected]] Gesendet: Montag, 22. November 2010 13:39 An: Log4J Users List Cc: [email protected] Betreff: Re: Logging to File uncomment the "log4j.appender" lines. ■DOUGLAS E. WEGSCHEID // LEAD ENGINEER (269) 923-5278 // [email protected] "A wrong note played hesitatingly is a wrong note. A wrong note played with conviction is interpretation." Clement Jebakumar <[email protected]> 11/20/2010 09:21 AM Please respond to "Log4J Users List" <[email protected]> To [email protected] cc Subject Logging to File Hi, How do i set all logs to a file. I am setting the property file. Do i need to change something? Bellow is my property file and code sample LogProperty.log # Set root logger level to DEBUG and its only appender to A1. log4j.rootLogger=WARN, A1 # A1 is set to be a ConsoleAppender. # log4j.appender.A1=org.apache.log4j.ConsoleAppender # A1 uses PatternLayout. # log4j.appender.A1.layout=org.apache.log4j.PatternLayout # log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n log4j.logger.com.declum=WARN Code: PropertyConfigurator.configure(line.getOptionProperties("l")); Logger.getLogger(getClass()).info("Star listening on " + monitorPort); *Clement Jebakumar,* 111/27 Keelamutharamman Kovil Street, Tenkasi, 627 811 http://www.declum.com/clement.html --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
