# OLAP Log Output

The Pentaho Server and the standalone Mondrian engine both use `log4j` to record information about generated OLAP-generated SQL queries. It may be useful to examine this log output if you are having trouble with configuration or performance-tuning.

#### Analysis SQL output logging

You can log SQL generation, MDX generation, and debug MDX execution information in the Pentaho Server, Mondrian engine, or Schema Workbench.

The existing `log4j2.xml` configuration in the Pentaho Server includes the following rolling file appenders:

* **SQLLOG**

  Logs all SQLs generated by Mondrian including execution times and row counts. Executing the same MDX statement a second time will generally result in no additional SQL logging because Mondrian caches data from the first MDX statement
* **MDXLOG**

  Logs all MDXs executed by Mondrian including execution times.
* **MONDRIAN**

  Logs detailed MDX execution information such as dynamic schema processors used, aggregate tables found, segment creation, execution phase events, named set evaluations, etc. Only use this appender to troubleshoot specific schemas and queries as it generates extremely verbose logging.

Follow the directions below to turn on this SQL logging.

1. Stop the Pentaho Server standalone Mondrian engine or Schema Workbench.
2. Open the `log4j2`.xml configuration file in a text editor. For Pentaho Server, this is located in the `server/pentaho-server/tomcat/webapps/pentaho/WEB-INF/classes` directory. For standalone Mondrian engine, this depends on your runtime environment such as whether `log4j2.xml` is read from the classpath or configured as a JVM parameter. For Schema Workbench, please refer to the `workbench.bat/sh` startup script to find the location of `log4j2`.xml
3. Add the `log4j` appender and associated logger. By default, each appender has its own logger that references that appender via the appender-ref attribute. If you are enabling logging for a standalone Mondrian engine or Schema Workbench, refer to an existing Pentaho Server installation and copy the relevent appenders and loggers into the `log4j2`.xml used by Mondrian or Schema Workbench.
4. Save and close the file.
5. Start the Pentaho Server, Mondrian engine, or Schema Workbench.

A significant amount of Analysis query debugging information will now be available in your application server's logs. Some data about the segment cache plugin will also appear, but there are some other steps to take beyond this if you want log data specific to the segment cache. For more information, see: [Enabling segment cache logging](/install/10.2-install/multidimensional-data-modeling-in-pentaho/olap-log-output/enabling-segment-cache-logging.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pentaho.com/install/10.2-install/multidimensional-data-modeling-in-pentaho/olap-log-output.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
