Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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?
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic