File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes Can't able to write errors/exception in file using log4j Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Can Watch "Can New topic
Author

Can't able to write errors/exception in file using log4j

navneet rajput
Greenhorn

Joined: Sep 01, 2008
Posts: 14
Hello All,

I have written log module for generating logs at server side.
Log file created at server side and it is able to write normal logs in to that file, but I have used exception handling and I want to write logs which are throws in my code.
Also I want to write error logs in to that log file.

Please give me some pointers on the same. Any kind of help will be appreciated. Please see the following log4j configuration file for more reference.


########## this is root logger. Logging level set as ERROR ########################

log4j.rootLogger=debug,FILE,stdout
log4j.debug=true

############# This is Appender for writting logs at console #######################

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{MMM dd HH:mm:ss}] %-4r [%t] %-5p %c %x - %m%n

############ This is appender for writing logs in File ###########################

log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.file=C:\\MyLog_log\\Info.log
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=[%d{MMM dd HH:mm:ss}] %-4r [%t] %-5p %c %x - %m%n

########### This is Appender for defining Max log file size ######################

log4j.appender.MaxFileSize=1000KB

##################################################################################
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
What part are you having trouble with?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't able to write errors/exception in file using log4j