Results 1 to 3 of 3
  1. #1
    mattlindsay is offline Member
    Join Date
    Apr 2011
    Posts
    8
    Rep Power
    0

    Default Stop Java Logger writing the calling Class?

    All,

    I have written a simple class that user the java logger to write to a file. The problem I have is that because the logger is always called from the same class, every other line reads the same. for example, the output might be:

    03-Apr-2011 17:37:16 org.mymodule.LibLog.LibLog writeMessage
    INFO: 2011-04-03 17:37:16 Logger created
    03-Apr-2011 17:37:16 org.mymodule.LibLog.LibLog writeMessage
    INFO: 2011-04-03 17:37:16 Conductor loaded
    03-Apr-2011 17:37:16 org.mymodule.LibLog.LibLog writeMessage
    INFO: 2011-04-03 17:37:16 Creating a Pooling object
    03-Apr-2011 17:37:16 org.mymodule.LibLog.LibLog writeMessage
    INFO: 2011-04-03 17:37:16 Entered the Pooling module

    Is there a way to stop logger writing that out?

    Many thanks for your time

    Matt

  2. #2
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Smile

    You need to play with Appender & Patternlayout associated with the logger.

    Where in:
    %d{dd MMM yyyy HH:MM:ss } is used for --> Date, format see java.text.SimpleDateFormat
    %F is used for --> File name
    %l is used for --> Location (caution: compiler-option-dependently)
    %L is used for --> Line number
    %m is used for --> user-defined message
    %M is used for --> Method name
    %p is used for --> Level
    %r is used for --> Milliseconds since program start
    %t is used for --> Threadname

  3. #3
    mattlindsay is offline Member
    Join Date
    Apr 2011
    Posts
    8
    Rep Power
    0

    Default

    thanks for the answer lovelesh,

    I'm using the standard java logger (not log4j) and I'm not too sure what you mean by the Appender & Patternlayout associated with the logger?! I'm using a FileHandler and SimpleFormatter for that. Do you think you could point me in the right direction a little more?

    Thanks for your time, it is appreciated!

    Matt

Similar Threads

  1. Use stop button to stop moving (stop timers) on JPanel
    By mneskovic in forum New To Java
    Replies: 3
    Last Post: 07-23-2010, 12:50 PM
  2. log4j class logger disabling
    By lowlyintern in forum New To Java
    Replies: 1
    Last Post: 06-18-2010, 01:49 PM
  3. log4j class logger disabling
    By lowlyintern in forum Advanced Java
    Replies: 2
    Last Post: 06-17-2010, 02:51 PM
  4. Calling a variable from a different java class
    By jdiesel in forum New To Java
    Replies: 4
    Last Post: 01-09-2009, 01:12 AM
  5. calling a java class from html
    By Ed in forum Advanced Java
    Replies: 1
    Last Post: 07-08-2007, 12:58 AM

Posting Permissions

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