Results 1 to 4 of 4
- 03-03-2009, 01:37 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 99
- Rep Power
- 0
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
- 03-03-2009, 02:23 PM #2
Member
- Join Date
- Dec 2008
- Posts
- 99
- Rep Power
- 0
another question -
How can I remove the logger lines from the consule?
- 03-03-2009, 02:38 PM #3
Member
- Join Date
- Dec 2008
- Posts
- 99
- Rep Power
- 0
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?
- 03-03-2009, 10:35 PM #4
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
-
Java NetBeans IDE 6.1 Desing out of control, help needed!!! Please...
By equattro in forum NetBeansReplies: 1Last Post: 12-30-2010, 01:48 PM -
Excel macros to control Java application
By musicgold in forum Advanced JavaReplies: 8Last Post: 04-25-2009, 10:43 PM -
control app width based on certain control
By thebillybobjr in forum SWT / JFaceReplies: 0Last Post: 05-15-2008, 04:52 PM -
Java Control Panel not saving changes when I press OK
By RebelScum in forum New To JavaReplies: 0Last Post: 03-21-2008, 04:22 PM -
Help with key Logger in java
By paul in forum Advanced JavaReplies: 1Last Post: 08-07-2007, 05:14 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks