FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Logger

 
Post new topic   Reply to topic     Forum Index -> Mango
View previous topic :: View next topic  
Author Message
dubuila



Joined: 22 Aug 2006
Posts: 28

PostPosted: Tue Jan 30, 2007 9:25 am    Post subject: Logger Reply with quote

Hello,

I integrated the logger in my code but I always see the console ouput.
Is there a way to avoid it ?

Is there a way to build a more detailled XmlLayout sample and use it in my code ?

I will need log for me application. If I can help on some points here let me know. ( I'm a newbee in D be aware).

Cheers,
Laurent.

*** Added Log Code ***


int main(char[][] args)
{
Logger my_Logger;
PropertyConfigurator my_PropertyConfigurator;

try
{
my_PropertyConfigurator.configure (r"../config/logger/logger.properties");
my_Logger = Logger.getLogger (r"org.hyridia.crk.main");
my_Logger.addAppender (new FileAppender (new FilePath(r"../../../runtime/logger/logger.xml"), new XmlLayout));

my_Logger.trace ("Trace Done");
my_Logger.info ("Done");
}
catch (Object x)
{
my_Logger.fatal (x.toString);
}

return 0;
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Tue Jan 30, 2007 1:05 pm    Post subject: Reply with quote

Sure you can Smile

my_PropertyConfigurator.configure (r"../config/logger/logger.properties"); is the guy who adds a console appender, so you could avoid calling that? It's just a wrapper for a few common operations, so you can drop it or take a look at what it does?

Adding new Layout is pretty trivial. Use the XmlLayout as a template for your own class, and replace the new XmlLayout above with your own class.

See the log4j site for high level details on how this all works. We'll have our own documentation available really soon Smile
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Thu Feb 01, 2007 1:44 pm    Post subject: Reply with quote

follow up: you'll find a really well written turtorial on this over at Tango: http://www.dsource.org/projects/tango/wiki/ChapterLogging

The import names are different, but the rest is almost identical. Hope this helps.
Back to top
View user's profile Send private message
dubuila



Joined: 22 Aug 2006
Posts: 28

PostPosted: Fri Feb 02, 2007 3:43 am    Post subject: Reply with quote

Hello,

Thanks.

I can drop my_PropertyConfigurator.configure but...is it not the command that also the looger to be configured ? I plan to allow the final user to select his trace level by external configuration files.

Thanks for the Tango link, will help me.

It's generates others questions :

When will be your doc release ? on Svn ?

Is Tango related to Mango ? Need I use Tango logger or Mango logger ?

Cheers,
Laurent.
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Fri Feb 02, 2007 11:12 am    Post subject: Reply with quote

Sorry about the confusion here.

Unless you're using phobos, I'd recommend using the Tango logging software instead. The two packages are almost identical, but Tango is where this part of the Mango code will be manitained. The changeover should be as simple as renaming the imports. If you're using phobos, then you ought to stick with Mango code instead, since that is compatible with Phobos via a -version setting.

See the upcoming announcement for more details.

As for the PropertyConfigurator, it does add a default ConsoleAppender. Hrm, that's not right at all Sad

That will be remedied soon, but in the meantime you can remove that default ConsoleAppender via this command:
Code:

Log.getRootLogger.clearAppenders();

Which will remove the ConsoleAppender, and all others, from the logger root. Effectively, this will disable all output across the entire logger system (since there's no appenders to utilize).
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Mango All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group