Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

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

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

##################################################################################
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What part are you having trouble with?
 
please buy this thing and then I get a fat cut of the action:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!