logging configurator

Peter Donald <peter-4lf8KW9E9MLMqX/[email protected]>
Newsgroups gmane.comp.java.spice.devel
Message-ID <[email protected]>
Hi,

For a couple of years now there has been people asking for "admin oriented" 
logging configuration in Phoenix and a few other apps. Unfortunately the 
logging now is more oriented towards the developer rather than the end user. 
I am currently writing up a bunch of documentation and this has become 
painfully obvious to me. So I was planning on putting together something that 
would make logging easier for admins.

One of the best systems for admin style configuration is Unixs syslog. While 
each different syslog daemon has a slightly different format for 
configuration I have attached a representative format from a Mandrake linux.

You will notice that each line defines what a category (such as kern or news) 
and a priority (such as debug or warn). Under syslog the categorys are fixed 
and so are the prioritys.

I want to use the same sort of ideas but convert it into xml and allow user 
defined sets of levels. I was thinking about having a configuration format 
such as 

<logging version="1.0" packages="org.spice.logconf.lib">

  <destination name="dest1" type="File" target="/var/logs/myapp.log"/>
  <destination name="dest2" type="RotatingFile" target="/var/logs/dest2.log">
  ...config goes here...
  </destination>

  <channels destination="dest1">
    <include name="*.auth"/>
    <exclude name="http.*"/>
    <include name="network.encoder" priority="WARN"/>
  </channels>
</logging>

To use this you try to instantiate each destination by appending its Type to 
the list of packages and then with out any package prefixes. In this case 
dest1 would try to instantiate "org.spice.logconf.lib.File" and then "File" 
destinations. Each destination is then attached to loggers that are specified 
in channels declaration.

Another possible configuration format being.

<logging version="1.0" packages="org.spice.logconf.lib">

  <destination name="dest1" type="File" target="/var/logs/myapp.log">
    <channels>
      <include name="*.auth"/>
      <exclude name="http.*"/>
      <include name="network.encoder" priority="WARN"/>
    </channels>
  </destination>

  <destination name="dest2" type="RotatingFile" target="/var/logs/dest2.log">
    <config>
    ...config goes here...
    </config>
    <channels>
      <include name="*.auth"/>
      <exclude name="http.*"/>
      <include name="network.encoder" priority="WARN"/>
    </channels>
  </destination>

</logging>

It will use some of the ideas from the Excalibur logger toolkit but probably 
be more focused on providing admins ease of use and easy mechanism to 
validate logging configs. Some people have also asked for the ability to 
throw exceptions when a new logger category is created that has not been 
accounted for.

Thoughts? 

Any better config formats?



-- 
Cheers,

Peter Donald
*------------------------------------------------------*
| Despite your efforts to be a romantic hero, you will |
| gradually evolve into a postmodern plot device.      |
*------------------------------------------------------*
syslog.conf (text/plain, 1.6 KB)
# Various entry
auth,authpriv.*							/var/log/auth.log
*.*;auth,authpriv.none						-/var/log/syslog
user.*								-/var/log/user.log

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;;news.none;authpriv.none					-/var/log/messages

# The authpriv file has restricted access.
authpriv.*							/var/log/secure

# Mail logging
mail.=debug;mail.=info;mail.=notice				-/var/log/mail/info
mail.=warn							-/var/log/mail/warnings
mail.err							-/var/log/mail/errors

# Cron logging
cron.=debug;cron.=info;cron.=notice				-/var/log/cron/info
cron.=warn							-/var/log/cron/warnings
cron.err							-/var/log/cron/errors

# Kernel logging
kern.=debug;kern.=info;kern.=notice				-/var/log/kernel/info
kern.=warn							-/var/log/kernel/warnings
kern.err							/var/log/kernel/errors

# Lpr logging
lpr.=debug;lpr.=info;lpr.=notice				-/var/log/lpr/info
lpr.=warn							-/var/log/lpr/warnings
lpr.err								-/var/log/lpr/errors

# News logging
news.=debug;news.=info;news.=notice				-/var/log/news/news.notice
news.=crit							-/var/log/news/news.crit
news.=err							-/var/log/news/news.err

# Daemons logging
daemon.=debug;daemon.=info;daemon.=notice			-/var/log/daemons/info
daemon.=warn							-/var/log/daemons/warnings
daemon.err							-/var/log/daemons/errors


# Everybody gets emergency messages
*.emerg								*

# Save mail and news errors of level err and higher in a
# special file.
uucp,news.crit							-/var/log/spooler

# Save boot messages also to boot.log
local7.*							-/var/log/boot.log

# Explanations from Mandrake Linux configuration tools
local1.*							-/var/log/explanations
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.