Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: + MGNLCE-363

...

TypeLocationDescription
log4j2.xml
Div
/WEB-INF/config/default
A permanent configuration which persists restarts. In the XML file you can also choose whether you wish to log a Class or package. Any changes made to the file will require a restart of the server.
Log Tools appTools menuA transient configuration which resets after a restart. In the Log Tools app you can choose whether you wish to log a Class or package. Any changes made in the app are active immediately. This tool is useful for ad-hoc debugging of production issues since you don't need to restart Magnolia to turn it on.
Audit Logging
Div
/server/auditLogging
Audit logging means tracking user activity in the system such as who signed in and what they did. Here you select the actions you want to audit such as login, create, activate and so on.

...

Level

Description

OFF

The highest possible rank and is intended to turn off logging.

FATAL

Severe errors that cause premature termination. Visible in console.

ERROR

Other runtime errors or unexpected conditions. Visible in console.

WARN

Use of deprecated APIs, poor use of API, "almost" errors, other runtime situations that are undesirable or unexpected, but not necessarily "wrong". Visible in console.

INFO

Interesting runtime events (startup/shutdown). Visible in console, so be conservative and keep to a minimum.

DEBUG

Detailed information on the flow through the system. Written to logs only.

TRACE

More detailed information. Written to logs only.

Pattern layout

Log4j2's Pattern Layout is a customizable log message formatter that uses conversion patterns to generate structured log outputs.

Note

The log message is encoded to address CWE 117 (Improper Output Neutralization for Logs), ensuring user-supplied data is properly sanitized so as to prevent log injection attacks.

Example PatternLayout

Code Block
languagebash
<PatternLayout pattern="%d %-5p %-50.50c: %encode{%m}{CRLF}%n"/>

The above pattern matches:

  • %d = the date.
  • %-5p = the priority (p) left-justified by 5 characters.
  • %-50.50c: = the name of the logger that published the logging event.
  • %encode{%m}{CRLF}%n = encodes the user message preventing the CRLF characters from the stream.

Appenders

Appenders define where the output is directed. The following appenders are configured by default in log4j2.xml. They write messages to the console and to various log files.

Appender

Writes to

Notes

console

Console

Default output for DEBUG messages

log-debug

magnolia-debug.log

Default output for DEBUG messages.

log-error

magnolia-error.log

Default output for ERROR messages.

log-publishing

magnolia-publishing.log

Content publishing.

log-bootstrap

bootstrap.log

Bootstrap process.

log-access

magnolia-access.log

System access.

log-audit

magnolia-audit.log

See Audit.

log-form

magnolia-form.log

See Form logging Logging form data.

mail

Sends mail.

Disabled by default.

...

It is also possible to adjust the log4j settings from inside a running instance. This is a transient configuration which resets after a restart. From the Log Tools app you can choose whether you wish to log a Class or package. Any changes made in the app are active immediately. This tool is useful for ad-hoc debugging of production issues since you don't need to restart Magnolia to turn it on.

...

To capture the headers, you can use a browser extension or plugin that displays headers for the currently open page. A plugin's advantage over a Monitoring#Websites Websites is that you can also use it for sites that only exist in your local environment or intranet.

...

  1. Open Developer Tools.
  2. Go to Network.
  3. Reload the page.
  4. Select the page in the list.
  5. Go to Headers tab.

Image RemovedImage Added

Command line tools

...

Java Monitoring and Management Console (JConsole) is a graphical tool that supports JMX monitoring and management on a local or remote machine. It draws graphs for visual representation of performance and resource consumption, which makes it easier to observe changes over time. As a downside, the results are not as easy to export as with Monitoring#Jmxterm Jmxterm.

Starting JConsole

  1. Start JConsole: $ jconsole
  2. Connect to a process:
    • Local: Select a Java process running on the local machine. Magnolia running on Tomcat would be listed as org.apache.catalina.startup.Boostrap start.
    • Remote: Type a remote process location as <hostname>:<port> or service:jmx:<protocol>:<sap>.
  3. Click Connect

...