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 Clement Jebakumar <je...@gmail.com> on 2010/11/20 15:21:50 UTC

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

AW: Logging to File

Posted by Stadelmann Josef <jo...@axa-winterthur.ch>.
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:Douglas_E_Wegscheid@whirlpool.com] 
Gesendet: Montag, 22. November 2010 13:39
An: Log4J Users List
Cc: log4j-user@logging.apache.org
Betreff: Re: Logging to File

uncomment the "log4j.appender" lines.
■ DOUGLAS E. WEGSCHEID // LEAD ENGINEER
(269) 923-5278 // Douglas_E_Wegscheid@whirlpool.com
"A wrong note played hesitatingly is a wrong note. A wrong note played 
with conviction is interpretation."



Clement Jebakumar <je...@gmail.com> 
11/20/2010 09:21 AM
Please respond to
"Log4J Users List" <lo...@logging.apache.org>


To
log4j-user@logging.apache.org
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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Logging to File

Posted by Douglas E Wegscheid <Do...@whirlpool.com>.
uncomment the "log4j.appender" lines.
■ DOUGLAS E. WEGSCHEID // LEAD ENGINEER
(269) 923-5278 // Douglas_E_Wegscheid@whirlpool.com
"A wrong note played hesitatingly is a wrong note. A wrong note played 
with conviction is interpretation."



Clement Jebakumar <je...@gmail.com> 
11/20/2010 09:21 AM
Please respond to
"Log4J Users List" <lo...@logging.apache.org>


To
log4j-user@logging.apache.org
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