View previous topic :: View next topic |
Author |
Message |
dubuila
Joined: 22 Aug 2006 Posts: 28
|
Posted: Tue Jan 30, 2007 9:25 am Post subject: Logger |
|
|
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 |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Tue Jan 30, 2007 1:05 pm Post subject: |
|
|
Sure you can
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 |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
|
Back to top |
|
|
dubuila
Joined: 22 Aug 2006 Posts: 28
|
Posted: Fri Feb 02, 2007 3:43 am Post subject: |
|
|
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 |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Fri Feb 02, 2007 11:12 am Post subject: |
|
|
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
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 |
|
|
|