aspose file tools*
The moose likes Other Open Source Projects and the fly likes Centralised Logging in Application in Source Filename, Methodname , Line Number format. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Centralised Logging in Application in Source Filename, Methodname , Line Number format." Watch "Centralised Logging in Application in Source Filename, Methodname , Line Number format." New topic
Author

Centralised Logging in Application in Source Filename, Methodname , Line Number format.

Piyush Patel
Ranch Hand

Joined: Feb 24, 2009
Posts: 127

hello friends,

in my Swing app, i created one LogWriter class.
to log statement from LoginForm.java file

i call LogWriter.init().
and then LogWriter.write("Login Succesfull or any message here");

output message is,
08/04/2010 11:11:19 AM com.piyush.util.LogWriter write
INFO: Login Successful or any message here

but i wanted it to be like, Source Filename, Methodname , Line Number format.
08/04/2010 11:11:19 AM com.piyush.LoginForm Login 39 (39 is line number in LogiForm.java)
INFO: Login Successful or any message here


see LogWriter.java

One more Question ,
Does logging run as Thread by default or developer needs to take care of this?
help ;)
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

If I remember correctly the Log4J logging spawns its own thread(s) to log, as for the formatting, you should read the log4j documetnation and alter you log4j.xml appropriately.

Actually it looks like you're creating your own formatter, you'll need to read the Javadoc API for log4j to figure out what you need to set.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Piyush Patel
Ranch Hand

Joined: Feb 24, 2009
Posts: 127

hi,Martijn thanks for your reply.
can you tell me is my approach for centralized logging is right? need advice on this.

thanks ;)
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

It's reasonable to have centralised services yes. Just make sure you're not duplicating effort of what Log4j already provides for you out of the box and make sure that the service is light weight!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Centralised Logging in Application in Source Filename, Methodname , Line Number format.