webgui logging · 2017-06-14 · log4perl log::log4perl lets you remote-control and fine-tune the...

50
WebGUI Logging JT Smith :: WUC 2007

Upload: others

Post on 26-May-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

WebGUI LoggingJT Smith :: WUC 2007

Page 2: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Logging?WTF can you do with a log file?

Page 3: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular (Java-based) Log4j logging package in pure Perl.

Page 4: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

log.confLogging is all about the config file.

Page 5: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

log.conflog4perl.logger = WARN, mainlog

log4perl.appender.mainlog = Log::Log4perl::Appender::File

log4perl.appender.mainlog.filename = /data/wre/var/logs/webgui.log

log4perl.appender.mainlog.layout = PatternLayout

log4perl.appender.mainlog.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

Page 6: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

log.conflog4perl.logger = WARN, mainlog

log4perl.appender.mainlog = Log::Log4perl::Appender::File

log4perl.appender.mainlog.filename = /data/wre/var/logs/webgui.log

log4perl.appender.mainlog.layout = PatternLayout

log4perl.appender.mainlog.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

Category NameIn this case, the master category.

Page 7: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

log.conflog4perl.logger = WARN, mainlog

log4perl.appender.mainlog = Log::Log4perl::Appender::File

log4perl.appender.mainlog.filename = /data/wre/var/logs/webgui.log

log4perl.appender.mainlog.layout = PatternLayout

log4perl.appender.mainlog.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

Log LevelDEBUG, INFO, WARN, ERROR, FATAL

Page 8: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

log.conflog4perl.logger = WARN, mainlog

log4perl.appender.mainlog = Log::Log4perl::Appender::File

log4perl.appender.mainlog.filename = /data/wre/var/logs/webgui.log

log4perl.appender.mainlog.layout = PatternLayout

log4perl.appender.mainlog.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

Log Alias DefinedLog Alias

Used

Page 9: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

log.conflog4perl.logger = WARN, mainlog

log4perl.appender.mainlog = Log::Log4perl::Appender::File

log4perl.appender.mainlog.filename = /data/wre/var/logs/webgui.log

log4perl.appender.mainlog.layout = PatternLayout

log4perl.appender.mainlog.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

Define a storage/display mechanism called an

Appender

Page 10: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

log.conflog4perl.logger = WARN, mainlog

log4perl.appender.mainlog = Log::Log4perl::Appender::File

log4perl.appender.mainlog.filename = /data/wre/var/logs/webgui.log

log4perl.appender.mainlog.layout = PatternLayout

log4perl.appender.mainlog.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

Appender Configuration

Page 11: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Log Per Sitelog4perl.logger.www.example.com = WARN, web log4perl.appender.web = Log::Log4perl::Appender::Filelog4perl.appender.web.filename = /data/wre/var/logs/www.example.com.log log4perl.appender.web.layout = PatternLayoutlog4perl.appender.web.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

log4perl.logger.intranet.example.com = WARN, intranetlog4perl.appender.intranet = Log::Log4perl::Appender::Filelog4perl.appender.intranet.filename = /data/wre/var/logs/intranet.example.com.log log4perl.appender.intranet.layout = PatternLayoutlog4perl.appender.intranet.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

Page 12: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Log Per Sitelog4perl.logger.www.example.com = WARN, web log4perl.appender.web = Log::Log4perl::Appender::Filelog4perl.appender.web.filename = /data/wre/var/logs/www.example.com.log log4perl.appender.web.layout = PatternLayoutlog4perl.appender.web.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

log4perl.logger.intranet.example.com = WARN, intranetlog4perl.appender.intranet = Log::Log4perl::Appender::Filelog4perl.appender.intranet.filename = /data/wre/var/logs/intranet.example.com.log log4perl.appender.intranet.layout = PatternLayoutlog4perl.appender.intranet.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

Page 13: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Log Per Sitelog4perl.logger.www.example.com = WARN, web log4perl.appender.web = Log::Log4perl::Appender::Filelog4perl.appender.web.filename = /data/wre/var/logs/www.example.com.log log4perl.appender.web.layout = PatternLayoutlog4perl.appender.web.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

log4perl.logger.intranet.example.com = WARN, intranetlog4perl.appender.intranet = Log::Log4perl::Appender::Filelog4perl.appender.intranet.filename = /data/wre/var/logs/intranet.example.com.log log4perl.appender.intranet.layout = PatternLayoutlog4perl.appender.intranet.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

WebGUI’s category is the config file name.

Page 14: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Log Per Site

log4perl.logger.www.example = WARN, weblog4perl.logger.www.example.com = WARN, web

log4perl.logger.www.example.com.conf = WARN, web

Probably the same thing unless there is an example.net or example.org in your sites list.

Page 15: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Log Per Site

log4perl.logger.www = WARN, web

All sites that begin with www.

Page 16: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Log Per Site

log4perl.logger.spectre.conf = WARN, web

Anything that S.P.E.C.T.R.E. logs.

Page 17: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Fatals Loglog4perl.logger = WARN, mainlog, fatals

# main log filelog4perl.appender.mainlog = Log::Log4perl::Appender::Filelog4perl.appender.mainlog.filename = /data/wre/var/logs/webgui.log log4perl.appender.mainlog.layout = PatternLayoutlog4perl.appender.mainlog.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

# log only containing fatalslog4perl.MatchFatals = Log::Log4perl::Filter::LevelMatchlog4perl.MatchFatals.LevelToMatch = FATALlog4perl.filter.MatchFatals.AcceptOnMatch = truelog4perl.appender.fatals.Filter = MatchFatalslog4perl.appender.fatals = Log::Log4perl::Appender::Filelog4perl.appender.fatals.filename = /data/wre/var/logs/webgui.fatal.log log4perl.appender.fatals.layout = PatternLayoutlog4perl.appender.fatals.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%nlog4perl.appender.fatals.Threshold = FATAL

Page 18: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Fatals Loglog4perl.logger = WARN, mainlog, fatals

# main log filelog4perl.appender.mainlog = Log::Log4perl::Appender::Filelog4perl.appender.mainlog.filename = /data/wre/var/logs/webgui.log log4perl.appender.mainlog.layout = PatternLayoutlog4perl.appender.mainlog.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

# log only containing fatalslog4perl.MatchFatals = Log::Log4perl::Filter::LevelMatchlog4perl.MatchFatals.LevelToMatch = FATALlog4perl.filter.MatchFatals.AcceptOnMatch = truelog4perl.appender.fatals.Filter = MatchFatalslog4perl.appender.fatals = Log::Log4perl::Appender::Filelog4perl.appender.fatals.filename = /data/wre/var/logs/webgui.fatal.log log4perl.appender.fatals.layout = PatternLayoutlog4perl.appender.fatals.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%nlog4perl.appender.fatals.Threshold = FATAL

Define an additionallog alias

Page 19: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Fatals Loglog4perl.logger = WARN, mainlog, fatals

# main log filelog4perl.appender.mainlog = Log::Log4perl::Appender::Filelog4perl.appender.mainlog.filename = /data/wre/var/logs/webgui.log log4perl.appender.mainlog.layout = PatternLayoutlog4perl.appender.mainlog.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

# log only containing fatalslog4perl.MatchFatals = Log::Log4perl::Filter::LevelMatchlog4perl.MatchFatals.LevelToMatch = FATALlog4perl.filter.MatchFatals.AcceptOnMatch = truelog4perl.appender.fatals.Filter = MatchFatalslog4perl.appender.fatals = Log::Log4perl::Appender::Filelog4perl.appender.fatals.filename = /data/wre/var/logs/webgui.fatal.log log4perl.appender.fatals.layout = PatternLayoutlog4perl.appender.fatals.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%nlog4perl.appender.fatals.Threshold = FATAL

Define a filterthat matchesonly FATALmessages.

Page 20: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Fatals Loglog4perl.logger = WARN, mainlog, fatals

# main log filelog4perl.appender.mainlog = Log::Log4perl::Appender::Filelog4perl.appender.mainlog.filename = /data/wre/var/logs/webgui.log log4perl.appender.mainlog.layout = PatternLayoutlog4perl.appender.mainlog.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

# log only containing fatalslog4perl.MatchFatals = Log::Log4perl::Filter::LevelMatchlog4perl.MatchFatals.LevelToMatch = FATALlog4perl.filter.MatchFatals.AcceptOnMatch = truelog4perl.appender.fatals.Filter = MatchFatalslog4perl.appender.fatals = Log::Log4perl::Appender::Filelog4perl.appender.fatals.filename = /data/wre/var/logs/webgui.fatal.log log4perl.appender.fatals.layout = PatternLayoutlog4perl.appender.fatals.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%nlog4perl.appender.fatals.Threshold = FATAL

Assign the filterto our fatals logalias.

Page 21: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Fatals Loglog4perl.logger = WARN, mainlog, fatals

# main log filelog4perl.appender.mainlog = Log::Log4perl::Appender::Filelog4perl.appender.mainlog.filename = /data/wre/var/logs/webgui.log log4perl.appender.mainlog.layout = PatternLayoutlog4perl.appender.mainlog.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

# log only containing fatalslog4perl.MatchFatals = Log::Log4perl::Filter::LevelMatchlog4perl.MatchFatals.LevelToMatch = FATALlog4perl.filter.MatchFatals.AcceptOnMatch = truelog4perl.appender.fatals.Filter = MatchFatalslog4perl.appender.fatals = Log::Log4perl::Appender::Filelog4perl.appender.fatals.filename = /data/wre/var/logs/webgui.fatal.log log4perl.appender.fatals.layout = PatternLayoutlog4perl.appender.fatals.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%nlog4perl.appender.fatals.Threshold = FATAL

Or instead of all thatwe could just add thisline to our appender.

Page 22: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Fatals Loglog4perl.logger = WARN, mainlog, fatals

# main log filelog4perl.appender.mainlog = Log::Log4perl::Appender::Filelog4perl.appender.mainlog.filename = /data/wre/var/logs/webgui.log log4perl.appender.mainlog.layout = PatternLayoutlog4perl.appender.mainlog.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%n

# log only containing fatalslog4perl.MatchFatals = Log::Log4perl::Filter::LevelMatchlog4perl.MatchFatals.LevelToMatch = FATALlog4perl.filter.MatchFatals.AcceptOnMatch = truelog4perl.appender.fatals.Filter = MatchFatalslog4perl.appender.fatals = Log::Log4perl::Appender::Filelog4perl.appender.fatals.filename = /data/wre/var/logs/webgui.fatal.log log4perl.appender.fatals.layout = PatternLayoutlog4perl.appender.fatals.layout.ConversionPattern = %d - %p - %c - %M[%L] - %m%nlog4perl.appender.fatals.Threshold = FATAL

The filter still has a place. You can use it for a specific level, where Threshold will append everything below the specified level.

Page 23: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Email Yourself Fatalslog4perl.category = FATAL, Mailerlog4perl.appender.Mailer = Log::Dispatch::Email::MailSendlog4perl.appender.Mailer.to = [email protected] = Something's broken!log4perl.appender.Mailer.layout = SimpleLayoutlog4perl.appender.Mailer.buffered = 0

Page 24: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Email Yourself Fatalslog4perl.category = FATAL, Mailerlog4perl.appender.Mailer = Log::Dispatch::Email::MailSendlog4perl.appender.Mailer.to = [email protected] = Something's broken!log4perl.appender.Mailer.layout = SimpleLayoutlog4perl.appender.Mailer.buffered = 0

You need to install this appender, because it doesn’t

come with log4perl.

Page 25: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Email Yourself Fatalslog4perl.category = FATAL, Mailerlog4perl.appender.Mailer = Log::Dispatch::Email::MailSendlog4perl.appender.Mailer.to = [email protected] = Something's broken!log4perl.appender.Mailer.layout = SimpleLayoutlog4perl.appender.Mailer.buffered = 0

Your email address. Or better yet, someone else’s

email address. =)

Page 26: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Email Yourself Fatalslog4perl.category = FATAL, Mailerlog4perl.appender.Mailer = Log::Dispatch::Email::MailSendlog4perl.appender.Mailer.to = [email protected] = Something's broken!log4perl.appender.Mailer.layout = SimpleLayoutlog4perl.appender.Mailer.buffered = 0

A subject line. I recommend something unique that you can use email filters on. Putting hostname in subject also a good idea.

Page 27: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Email Yourself Fatalslog4perl.category = FATAL, Mailerlog4perl.appender.Mailer = Log::Dispatch::Email::MailSendlog4perl.appender.Mailer.to = [email protected] = Something's broken!log4perl.appender.Mailer.layout = SimpleLayoutlog4perl.appender.Mailer.buffered = 0

Without this it would only email after building up a

few messages.

Page 28: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

IM Yourself Fatalslog4perl.category = FATAL, Jabberlog4perl.appender.Jabber = Log::Dispatch::Jabberlog4perl.appender.Jabber.login.hostname = jabber.example.comlog4perl.appender.Jabber.login.port = 5222log4perl.appender.Jabber.login.username = loggerlog4perl.appender.Jabber.login.password = 123qwelog4perl.appender.Jabber.login.resource = loggerlog4perl.appender.Jabber.to = [email protected] = SimpleLayoutlog4perl.appender.Jabber.buffer = 3

Page 29: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

IM Yourself Fatalslog4perl.category = FATAL, Jabberlog4perl.appender.Jabber = Log::Dispatch::Jabberlog4perl.appender.Jabber.login.hostname = jabber.example.comlog4perl.appender.Jabber.login.port = 5222log4perl.appender.Jabber.login.username = loggerlog4perl.appender.Jabber.login.password = 123qwelog4perl.appender.Jabber.login.resource = loggerlog4perl.appender.Jabber.to = [email protected] = SimpleLayoutlog4perl.appender.Jabber.buffer = 3

You’ll have to install this module.

Page 30: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

IM Yourself Fatalslog4perl.category = FATAL, Jabberlog4perl.appender.Jabber = Log::Dispatch::Jabberlog4perl.appender.Jabber.login.hostname = jabber.example.comlog4perl.appender.Jabber.login.port = 5222log4perl.appender.Jabber.login.username = webguilog4perl.appender.Jabber.login.password = 123qwelog4perl.appender.Jabber.login.resource = loggerlog4perl.appender.Jabber.to = [email protected] = SimpleLayoutlog4perl.appender.Jabber.buffer = 3

Specify all the login information required to access your jabber server. The logger needs it’s own account.

Page 31: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

IM Yourself Fatalslog4perl.category = FATAL, Jabberlog4perl.appender.Jabber = Log::Dispatch::Jabberlog4perl.appender.Jabber.login.hostname = jabber.example.comlog4perl.appender.Jabber.login.port = 5222log4perl.appender.Jabber.login.username = loggerlog4perl.appender.Jabber.login.password = 123qwelog4perl.appender.Jabber.login.resource = loggerlog4perl.appender.Jabber.to = [email protected] = SimpleLayoutlog4perl.appender.Jabber.buffer = 3

Specify who gets the message.

Page 32: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

IM Yourself Fatalslog4perl.category = FATAL, Jabberlog4perl.appender.Jabber = Log::Dispatch::Jabberlog4perl.appender.Jabber.login.hostname = jabber.example.comlog4perl.appender.Jabber.login.port = 5222log4perl.appender.Jabber.login.username = loggerlog4perl.appender.Jabber.login.password = 123qwelog4perl.appender.Jabber.login.resource = loggerlog4perl.appender.Jabber.to = [email protected] = SimpleLayoutlog4perl.appender.Jabber.buffer = 3

Specify how many fatals should be generated before sending a message.

Page 33: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Log to XMLlog4perl.logger = WARN, mainlog log4perl.appender.mainlog = Log::Log4perl::Appender::Filelog4perl.appender.mainlog.filename = /data/wre/var/logs/webgui.log log4perl.appender.mainlog.layout = Log::Log4perl::Layout::XMLLayoutlog4perl.appender.mainlog.layout.LocationInfo = TRUElog4perl.appender.mainlog.layout.Encoding = iso8859-1

Note that you have to install Log::Log4perl::Layout::XMLLayout

separately.

Page 34: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Log to XMLlog4perl.logger = WARN, mainlog log4perl.appender.mainlog = Log::Log4perl::Appender::Filelog4perl.appender.mainlog.filename = /data/wre/var/logs/webgui.log log4perl.appender.mainlog.layout = Log::Log4perl::Layout::XMLLayoutlog4perl.appender.mainlog.layout.LocationInfo = TRUElog4perl.appender.mainlog.layout.Encoding = iso8859-1

Just a new kind of layout system. But it’s easily readable by log file

analyzers like Chainsaw.

Page 35: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Chainsaw

Page 36: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Log to a Database log4perl.logger = WARN, mainlog log4perl.appender.mainlog = Log::Log4perl::Appender::DBIlog4perl.appender.mainlog.layout = Log::Log4perl::Layout::PatternLayoutlog4perl.appender.mainlog.datasource = DBI:mysql:thebigdblog4perl.appender.mainlog.username = webguilog4perl.appender.mainlog.password = 123qwelog4perl.appender.mainlog.sql = insert into my_log_table \ (loglevel, site, date, module, lineNumber, message) values (?,?,?,?,?,?)log4perl.appender.mainlog.params.1 = %plog4perl.appender.mainlog.params.2 = %clog4perl.appender.mainlog.params.3 = %dlog4perl.appender.mainlog.params.4 = %Mlog4perl.appender.mainlog.params.5 = %Llog4perl.appender.mainlog.params.6 = %mlog4perl.appender.mainlog.bufferSize = 3

Page 37: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Log to a Database log4perl.logger = WARN, mainlog log4perl.appender.mainlog = Log::Log4perl::Appender::DBIlog4perl.appender.mainlog.layout = Log::Log4perl::Layout::PatternLayoutlog4perl.appender.mainlog.datasource = DBI:mysql:thebigdblog4perl.appender.mainlog.username = webguilog4perl.appender.mainlog.password = 123qwelog4perl.appender.mainlog.sql = insert into my_log_table \ (loglevel, site, date, module, lineNumber, message) values (?,?,?,?,?,?)log4perl.appender.mainlog.params.1 = %plog4perl.appender.mainlog.params.2 = %clog4perl.appender.mainlog.params.3 = %dlog4perl.appender.mainlog.params.4 = %Mlog4perl.appender.mainlog.params.5 = %Llog4perl.appender.mainlog.params.6 = %mlog4perl.appender.mainlog.bufferSize = 3

We want to use the database appender.

Page 38: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Log to a Database log4perl.logger = WARN, mainlog log4perl.appender.mainlog = Log::Log4perl::Appender::DBIlog4perl.appender.mainlog.layout = Log::Log4perl::Layout::PatternLayoutlog4perl.appender.mainlog.datasource = DBI:mysql:thebigdblog4perl.appender.mainlog.username = webguilog4perl.appender.mainlog.password = 123qwelog4perl.appender.mainlog.sql = insert into my_log_table \ (loglevel, site, date, module, lineNumber, message) values (?,?,?,?,?,?)log4perl.appender.mainlog.params.1 = %plog4perl.appender.mainlog.params.2 = %clog4perl.appender.mainlog.params.3 = %dlog4perl.appender.mainlog.params.4 = %Mlog4perl.appender.mainlog.params.5 = %Llog4perl.appender.mainlog.params.6 = %mlog4perl.appender.mainlog.bufferSize = 3

Provide the database connection info.

Page 39: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Log to a Database log4perl.logger = WARN, mainlog log4perl.appender.mainlog = Log::Log4perl::Appender::DBIlog4perl.appender.mainlog.layout = Log::Log4perl::Layout::PatternLayoutlog4perl.appender.mainlog.datasource = DBI:mysql:thebigdblog4perl.appender.mainlog.username = webguilog4perl.appender.mainlog.password = 123qwelog4perl.appender.mainlog.sql = insert into my_log_table \ (loglevel, site, date, module, lineNumber, message) values (?,?,?,?,?,?)log4perl.appender.mainlog.params.1 = %plog4perl.appender.mainlog.params.2 = %clog4perl.appender.mainlog.params.3 = %dlog4perl.appender.mainlog.params.4 = %Mlog4perl.appender.mainlog.params.5 = %Llog4perl.appender.mainlog.params.6 = %mlog4perl.appender.mainlog.bufferSize = 3

Tie the log parameters to fields in a database table.

Page 40: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Log to a Database log4perl.logger = WARN, mainlog log4perl.appender.mainlog = Log::Log4perl::Appender::DBIlog4perl.appender.mainlog.layout = Log::Log4perl::Layout::PatternLayoutlog4perl.appender.mainlog.datasource = DBI:mysql:thebigdblog4perl.appender.mainlog.username = webguilog4perl.appender.mainlog.password = 123qwelog4perl.appender.mainlog.sql = insert into my_log_table \ (loglevel, site, date, module, lineNumber, message) values (?,?,?,?,?,?)log4perl.appender.mainlog.params.1 = %plog4perl.appender.mainlog.params.2 = %clog4perl.appender.mainlog.params.3 = %dlog4perl.appender.mainlog.params.4 = %Mlog4perl.appender.mainlog.params.5 = %Llog4perl.appender.mainlog.params.6 = %mlog4perl.appender.mainlog.bufferSize = 3

For efficiency sake only write after we’ve buffered 3 log messages.

Page 41: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Performance

Page 42: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Performance

The more you log, the slower it will be.

Page 43: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Performance

The more you log, the slower it will be.

WARN is the highest level you should use on a production site, and ERROR is recommended for busy sites.

Page 44: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Performance

The more you log, the slower it will be.

WARN is the highest level you should use on a production site, and ERROR is recommended for busy sites.

Use a site specific log if you must log with more detail.

Page 45: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Write an SMS Appenderpackage Log::Log4perl::SmsAppender;use strict;use Net::SMS;

sub log { my $self = shift; my $sms = Net::SMS->new(); $sms->subscriberID($self->{subscriberID}); $sms->subscriberPassword($self->{subscriberPassword}); $sms->msgPin($self->{to}); $sms->msgFrom("WebGUI"); $sms->msgCallback($self->{from}); $sms->msgText($self->{message}); $sms->optFlash($self->{gsmFlash} || "false"); $sms->msgSend;}

sub new { my ($class, %options) = @_; bless {%options}, $class;}

1;

Page 46: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Write an SMS Appenderlog4perl.category = FATAL, SMSlog4perl.appender.SMS = Log::Log4perl::SmsAppenderlog4perl.appender.SMS.subscriberID = 123-456-789-12345log4perl.appender.SMS.subscriberPassword = 123qwelog4perl.appender.SMS.to = +1 100 410 1234log4perl.appender.SMS.from = +1 100 510 1212log4perl.appender.SMS.gsmFlash = truelog4perl.appender.SMS.layout = SimpleLayout

Page 47: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Write an SMS Appenderlog4perl.category = FATAL, SMSlog4perl.appender.SMS = Log::Log4perl::SmsAppenderlog4perl.appender.SMS.subscriberID = 123-456-789-12345log4perl.appender.SMS.subscriberPassword = 123qwelog4perl.appender.SMS.to = +1 100 410 1234log4perl.appender.SMS.from = +1 100 510 1212log4perl.appender.SMS.gsmFlash = truelog4perl.appender.SMS.layout = SimpleLayout

Page 48: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Write an SMS Appenderpackage Log::Log4perl::SmsAppender;use strict;use Net::SMS;

sub log { my $self = shift; my $sms = Net::SMS->new(); $sms->subscriberID($self->{subscriberID}); $sms->subscriberPassword($self->{subscriberPassword}); $sms->msgPin($self->{to}); $sms->msgFrom("WebGUI"); $sms->msgCallback($self->{from}); $sms->msgText($self->{message}); $sms->optFlash($self->{gsmFlash} || "false"); $sms->msgSend;}

sub new { my ($class, %options) = @_; bless {%options}, $class;}

1;

Page 49: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Write an SMS Appenderpackage Log::Log4perl::SmsAppender;use strict;use Net::SMS;

sub log { my $self = shift; my $sms = Net::SMS->new(); $sms->subscriberID($self->{subscriberID}); $sms->subscriberPassword($self->{subscriberPassword}); $sms->msgPin($self->{to}); $sms->msgFrom("WebGUI"); $sms->msgCallback($self->{from}); $sms->msgText($self->{message}); $sms->optFlash($self->{gsmFlash} || "false"); $sms->msgSend;}

sub new { my ($class, %options) = @_; bless {%options}, $class;}

1;

Page 50: WebGUI Logging · 2017-06-14 · log4perl Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular

Questions?