Results 1 to 2 of 2

Thread: log4j questions

  1. #1
    giorashc is offline Member
    Join Date
    Feb 2010
    Posts
    1
    Rep Power
    0

    Default log4j questions

    I have 2 questions regarding log4j :

    1. How do I disable appending to the log files when running an application again ? (Now the logging is just being appended to the last run logging generating a very big log file)

    2. How can I disable logging to the console ? (Now every log I make is written to the proper file(s) but also to the console)

    Thanks in advance.

  2. #2
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    366
    Rep Power
    6

    Default

    What are your real logging purposes?

    Are you using log for info, debug or warns and errors?

    Is this logging for development or you have finished
    and you move your code to productional server?

    Is your logging file growing to fast?

    Who will read log file is something goes wrong? Developer? Client?

    Answer all those questions, and that will be input info for
    your log4j configuration in each development phase of your project.

    There are many appenders that can be used:
    ConsoleAppender, FileAppender, SMTPAppender, RollingFileAppender...

    How to you configure log4j? If you are using log4j.properties there will be:

    Java Code:
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    That is a place to add or remove your appenders.

    Also that is place where you set up your log level : trace, debug....fatal.

    If you have log file size problems you can use RollingFileAppender with
    DailyRollingFileAppender which creates on file per day, but configuring this
    in multithread app can be real pain.

    Take your time and study your logger configuration.

    cheers!

Similar Threads

  1. log4j
    By swapna_d in forum New To Java
    Replies: 7
    Last Post: 08-04-2010, 01:23 AM
  2. Log4j Issue
    By nag98 in forum Forum Lobby
    Replies: 0
    Last Post: 06-22-2008, 09:22 PM
  3. Regarding Log4j
    By sidiq in forum New To Java
    Replies: 0
    Last Post: 04-07-2008, 08:35 PM
  4. log4j with Applet
    By sunjavaboy in forum Java Applets
    Replies: 0
    Last Post: 03-25-2008, 01:13 AM
  5. Log4j
    By chakri in forum New To Java
    Replies: 1
    Last Post: 02-08-2008, 11:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •