In my recent mini-series, I have been talking about using the logger properly but it is also important to ensure that customisations aren’t using a painful alternative.
This article explains about one alternative and provides a link for information on writing log entries using the standard Maximo logger.
Background
All log entries are written to a destination normally mapped to either SystemOut.log or SystemErr.log.
Entries to SystemOut.log can look like this:
[1/17/17 21:15:25:411 GMT] 000000e3 SystemOut O 17 Jan 2017 21:15:25:411 [ERROR] [MAXIMO] [CID-CRON-64571] BMXAA7901E - You cannot log in at this time. Contact the system administrator.
When Websphere writes entries to a destination it prefixes the entry with the date/time and other details.
[1/17/17 21:15:25:411 GMT] 000000e3 SystemOut O
When the Maximo logger writes entries it adds another prefix with the date/time and other details e.g. the log level such as [ERROR]
17 Jan 2017 21:15:25:411 [ERROR]
Bad log entries
Developers can write code that bypasses the logger and just writes directly to the logs.
This code writes entries like this:
[1/17/17 21:15:25:411 GMT] 000000e3 SystemOut O MyText
There are a number of problems with this approach:
- These entries can’t be switched off by system administrators.
- The source isn’t clear – it could be Websphere logging the text using its logger
- Where the code generates a lot of entries this can lead to increased rollover and make it harder to identify the root cause of problems.
- The code needs to be modified to switch these messages off. If it is Java code then the class needs to be recompiled and the EAR file redeployed. System administrators in organisations with strict change control will recognise the sinking feeling that the code will never get changed because no one will authorise all the testing.
Why do developers use it?
- It is quick and easy to use.
- It is a standard tool used in non-Maximo Java applications.
- Developer may not be aware of the Maximo logger or want to learn about it
What does the code for this look like?
- System.out.print / System.out.println – used to write entries to the SystemOut.log file
- System.err.print / System.err.println – used to write entries to the SystemErr.log file
This can be seen in Java or automation scripts although it is unusual to see this in automation scripts.
Tip -> If you are given source code then search it for text like “out.print” and query whether it is valid. It is important to query this as early as possible
Tip -> Develop standards that projects must include and ban the use of problem code like this
What is the alternative to the System.out/err code?
Bruno has a good blog post here that explains how to use the standard loggers
Experienced developers can take it further e.g. adding conditions to ensure that the loggers are only called when the log level is at the correct level.
Next week
I'll be starting a new mini-series around risky behaviours that system administrators may see.
#Maximo#AssetandFacilitiesManagement