Hello,
I am trying to use the log/package.
In the logdemo program there is the following xml file.
<LogConfigurations>
<LogConfig name="ConfigName0">
<Appenders>
</Appenders>
</LogConfig>
<LogConfig name="ConfigNameMC">
<Appenders>
<Appender name="AppenderName2">
<LogLevel>all</LogLevel>
<Type>fileasync</Type>
<ThreadPriority>low</ThreadPriority>
<!--Target>%TEMP%\ideVault.log</Target-->
<Target>VIP %date{MM-dd} %time{HH.mm}.log</Target>
<PatternLayout>%lineno{4d} %time: %username [%callerClassName::%callerPredicateName] %msg</PatternLayout>
<!--PatternLayout>%time: %msg</PatternLayout-->
<filter>class:entityModel;method:aaa</filter>
</Appender>
<!--Appender name="AppenderName3">
<LogLevel>all</LogLevel>
<Type>dbtable</Type>
<PatternLayout>%userid %proc:%thread %datetime %msg</PatternLayout>
<filter>class:entityModel;method:aaa</filter>
</Appender-->
<Appender name="Appender Console">
<LogLevel>all</LogLevel>
<Type>console</Type>
<PatternLayout>%lineno{4d}. ~red %msglevel{-5s}~normal %time{HH:mm:ss} [%callerclassname::%callerPredicateName] %msg</PatternLayout>
<filter>class:entityModel;method:aaa</filter>
</Appender>
</Appenders>
</LogConfig>
</LogConfigurations>
Making a patternlayout is a problem.
I presume that the characters % { ~ and [ are delimiters.
But when and how are they used?
Kind regards
Ben
-
- VIP Member
- Posts: 1466
- Joined: 28 Feb 2000 0:01
Re: logging
I agree that there lack some documentation on that matter.
The log tool has two ends:
Here is a cleaned version of the configuration from the example (the token coloring is not the best for XML, but anyways):
It configures two appenders AppenderName2 and Appender Console. The first is a "fileasync" appender which will create a log file with a name defined by <Target>; this log file will receive an entry for log events of all levels. Each entry will be formatted using the <PatternLayout>.
This should answer the "when is it used" part of the question.
In the <PatternLayout> you can use %<name> and %<name>{<format>} to format attributes from the event into the log entry. ~red and ~normal can only be used with the console, I think the demo and the names explains what they do.
The possible <name>'s can be found in $(ProDir)\pfc\log\formatter.pro:
The formatting you will have to "guess and experiment" with at present (or inspect the code of course).
The log tool has two ends:
- In the main parts of the program you insert calls to log events, by calling logging predicates in the log tool
- In the other end appenders will append log events to specific logs.
Here is a cleaned version of the configuration from the example (the token coloring is not the best for XML, but anyways):
Code: Select all
<LogConfigurations>
<LogConfig name="ConfigName">
<Appenders>
<Appender name="AppenderName2">
<LogLevel>all</LogLevel>
<Type>fileasync</Type>
<ThreadPriority>low</ThreadPriority>
<Target>
VIP %date{MM-dd} %time{HH.mm}.log
</Target>
<PatternLayout>
%lineno{4d} %time: %username [%callerClassName::%callerPredicateName] %msg
</PatternLayout>
<filter>class:entityModel;method:aaa</filter>
</Appender>
<Appender name="Appender Console">
<LogLevel>all</LogLevel>
<Type>console</Type>
<PatternLayout>
%lineno{4d}. ~red %msglevel{-5s}~normal %time{HH:mm:ss} [%callerclassname::%callerPredicateName] %msg
</PatternLayout>
<filter>class:entityModel;method:aaa</filter>
</Appender>
</Appenders>
</LogConfig>
</LogConfigurations>
This should answer the "when is it used" part of the question.
In the <PatternLayout> you can use %<name> and %<name>{<format>} to format attributes from the event into the log entry. ~red and ~normal can only be used with the console, I think the demo and the names explains what they do.
The possible <name>'s can be found in $(ProDir)\pfc\log\formatter.pro:
Code: Select all
constants
proc = "proc".
thread = "thread".
userid = "userid".
username = "username".
date = "date".
time = "time".
msg = "msg".
msglevel = "msglevel".
newline = "newline".
callerClassName = "callerclassname".
callerPredicateName = "callerpredicatename".
callerCursor = "callercursor".
linenumber = "lineno".
seqnumber = "seqno".
applicationName = "applicationname".
Regards Thomas Linder Puls
PDC
PDC
-
- VIP Member
- Posts: 57
- Joined: 11 Jul 2002 23:01
Re: logging
Thank you Thomas,
I will study it further.
Kind regards
Ben
I will study it further.
Kind regards
Ben