Results 1 to 4 of 4
  1. #1
    itaipee is offline Member
    Join Date
    Dec 2008
    Posts
    99
    Rep Power
    0

    Default Java Logger ( How to control it better)

    I try using logs. in the mean time it work not bad but the problem is that I get for every messege I print in the log - two lines.
    the first line includes date, class and method
    Second line include the messege.

    How can I make it one line only ?

    Othe option - the first line will be types only one time per method ( incase of lop , ect.. )
    Ho can I do it?



    Mar 3, 2009 2:21:34 PM flows.Seal makeLog
    INFO: Start Log File
    Mar 3, 2009 2:21:34 PM flows.Seal initialize
    INFO: using BorderLayout
    Mar 3, 2009 2:21:34 PM flows.Seal setAddAllComp
    INFO: Import to FCM all Components: false
    Mar 3, 2009 2:21:34 PM flows.Seal setGlobal
    INFO: set new Global :user <= null
    Mar 3, 2009 2:21:34 PM flows.ManageSPC <init>
    INFO: good

  2. #2
    itaipee is offline Member
    Join Date
    Dec 2008
    Posts
    99
    Rep Power
    0

    Default

    another question -
    How can I remove the logger lines from the consule?

  3. #3
    itaipee is offline Member
    Join Date
    Dec 2008
    Posts
    99
    Rep Power
    0

    Default

    Also , can I make that all warning and severe will be writen to one file and all indo to other and all fine to another?

  4. #4
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    reply to post
    #1: No, i don't think so...
    #2: take a look at the api. java.util.logging.Logger
    #3: Yes You Can! But its hectic. (unless someone proves me wrong and i'm no expert.)
    You'd need something like this for every level.
    Java Code:
        Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
        FileHandler fhFinest [COLOR=BLACK]=[/COLOR] [COLOR=NAVY]new[/COLOR] FileHandler[COLOR=BLACK]([/COLOR][COLOR=SILVER]"c:/fhFinest.log"[/COLOR][COLOR=BLACK])[/COLOR][COLOR=BLACK];[/COLOR]
        fhFinest[COLOR=BLACK].[/COLOR]setLevel[COLOR=BLACK]([/COLOR]Level[COLOR=BLACK].[/COLOR]FINEST[COLOR=BLACK])[/COLOR][COLOR=BLACK];[/COLOR]
        fhFinest[COLOR=BLACK].[/COLOR]setFilter[COLOR=BLACK]([/COLOR][COLOR=NAVY]new[/COLOR] Filter[COLOR=BLACK]([/COLOR][COLOR=BLACK])[/COLOR][COLOR=BLACK]{[/COLOR]
          [COLOR=PURPLE]public[/COLOR] [COLOR=PURPLE]boolean[/COLOR] isLoggable[COLOR=BLACK]([/COLOR]LogRecord record[COLOR=BLACK])[/COLOR][COLOR=BLACK]{[/COLOR]
            [COLOR=NAVY]return[/COLOR] record[COLOR=BLACK].[/COLOR]getLevel[COLOR=BLACK]([/COLOR][COLOR=BLACK])[/COLOR] [COLOR=BLACK]==[/COLOR] Level[COLOR=BLACK].[/COLOR]FINEST[COLOR=BLACK];[/COLOR]
          [COLOR=BLACK]}[/COLOR][COLOR=BLACK]}[/COLOR][COLOR=BLACK])[/COLOR][COLOR=BLACK];[/COLOR]
        logger[COLOR=BLACK].[/COLOR]addHandler[COLOR=BLACK]([/COLOR]fhFinest[COLOR=BLACK])[/COLOR][COLOR=BLACK];[/COLOR]
        
        [COLOR=GREEN][I]// LOG STUFF[/I][/COLOR]
        logger[COLOR=BLACK].[/COLOR]setUseParentHandlers[COLOR=BLACK]([/COLOR][COLOR=NAVY][B]false[/B][/COLOR][COLOR=BLACK])[/COLOR][COLOR=BLACK];[/COLOR]
        logger[COLOR=BLACK].[/COLOR]setLevel[COLOR=BLACK]([/COLOR]Level[COLOR=BLACK].[/COLOR]ALL[COLOR=BLACK])[/COLOR][COLOR=BLACK];[/COLOR]
        logger[COLOR=BLACK].[/COLOR]finest[COLOR=BLACK]([/COLOR][COLOR=SILVER]"---------finest-----------"[/COLOR][COLOR=BLACK])[/COLOR][COLOR=BLACK];[/COLOR]
    
        fhFinest.close();
    Last edited by angryboy; 03-03-2009 at 10:46 PM.
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

Similar Threads

  1. Replies: 1
    Last Post: 12-30-2010, 01:48 PM
  2. Excel macros to control Java application
    By musicgold in forum Advanced Java
    Replies: 8
    Last Post: 04-25-2009, 10:43 PM
  3. control app width based on certain control
    By thebillybobjr in forum SWT / JFace
    Replies: 0
    Last Post: 05-15-2008, 04:52 PM
  4. Java Control Panel not saving changes when I press OK
    By RebelScum in forum New To Java
    Replies: 0
    Last Post: 03-21-2008, 04:22 PM
  5. Help with key Logger in java
    By paul in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 05:14 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
  •