0

Since my current assignment is to evaluate logging systems for use in Delphi XE 3, I'm trying to get to know Opensource solutions as well as CodeSite and SmartInspect. Currently I'm trying to get to know Log4Delphi but beside the little amount of documentation I encountered the following problem using Log4Delphi in Delphi XE3:

The basic logging functionality works quite fine. But I encountered a problem when I was trying to use the layout options to add further information like timestamps to my logging messages.

I use the following statement for loading my configuration file within the dpr-file:

TConfiguratorUnit.doPropertiesConfiguration(ExtractFileDir(Application.ExeName)+ '\MyLoggerconfig.properties');

At first I suspected there was a problem with the config files' path, so I wrote a different method which used the GetCurrentDir method. But I soon realised the config file is working.

No matter what kind of layout I choose in the config file, the appender keeps writing the log messages without using the proper formating. I tried to do exactly how the USer Guide of Log4Delphi told me. But currently I can'f figure out why it doesn't work properly.

var
  Form5: TForm5;
  logger: TLogger;
  layout : TLayout;
implementation

In order to use my logger I declared it as seen above.

logger := TLogger.GetInstance;
logger.SetLevel(TLevelUnit.ALL);

I use these two methods to initiliaze my logger in the mainforms oncreate event.

log4delphi.appender.fileAppender.layout=TPatternLayout
log4delphi.appender.fileAppender.layout.Pattern=%d{dd mmm yyyy hh:nn:ss:zzz} [%5p] %m%n

As you can see above I have chosen the default for the TPatternLayout and the log messages should contain various informations like timestamps. But instead the look like this:

WARN - Value of zahl1  2
WARN - Value of zahl2  4
TheLax
  • 93
  • 13
  • Try doBasicConfiguration then you know if config file caused the problem. – SimaWB Oct 01 '13 at 11:46
  • I already used doBasicConfiguration when I started using Log4Delphi.I've done some debugging and as I thought, the config is being read and there doesn't seem to be a problem with it. But yet the logfile stills shows no formatting. – TheLax Oct 01 '13 at 13:34
  • Did you try the Delphi debugger? It should hit the line which reads the layout configuration from MyLoggerConfig.properties. btw I also recommend Log4D, a different project but we switched all applications (from Log4Delphi) to use it – mjn Oct 01 '13 at 13:42
  • possible duplicate of [Delphi XE5 - strange behavior help needed](http://stackoverflow.com/questions/21432705/delphi-xe5-strange-behavior-help-needed) – Paul Sweatte Sep 12 '14 at 00:53

0 Answers0