{"data":{"markdownRemark":{"html":"<p>The Simudyne SDK uses SLF4J (Simple Logging Facade for Java) for logging. SLF4J is an abstraction over common logging frameworks which means it can be used with most common Java logging frameworks (e.g. java.util.logging, logback, log4j), so that if you are already using one of these frameworks you can continue using this framework for your simulation so that your logging is consistent.\nTo make use of this so that logging is not just done in the console, you will need to choose one of these frameworks to work with. For this example, we will be using Log4J.</p>\n<div class=\"ui segment info message\">\n<h4>Logging framework </h4>\nIf you want a specific framework, you will have to get the Slf4j binding for that framework and add it to your project. A list of bindings for different loggers can be found <a href=\"https://mvnrepository.com/artifact/org.slf4j\">here</a>.\n<p>However, <a href=\"https://logging.apache.org/log4j/2.x/\">log4j</a> is already present as a dependency if you choose to use it.</p>\n</div>\n<p>You will then need to follow the specific instructions for configuring the logger you have chosen, which can be found on the websites of the specific frameworks. We will be showing you an example configuration using log4j. More detailed instructions on configuring log4j can be found <a href=\"https://logging.apache.org/log4j/2.x/manual/configuration.html\">here</a>.</p>\n<p>There are many possible ways of configuring log4j. We will be using a properties file. Create a file called log4j.properties, in the resources folder of your project. (Resources folders are created in the path projectName/src/main/resources).</p>\n<p class=\"code-header\">log4j.properties</p>\n<div class=\"gatsby-highlight\" data-language=\"properties\"><pre class=\"language-properties\"><code class=\"language-properties\"><span class=\"token attr-name\">log4j.rootCategory</span><span class=\"token punctuation\">=</span><span class=\"token attr-value\">WARN, console</span>\n<span class=\"token attr-name\">log4j.appender.console</span><span class=\"token punctuation\">=</span><span class=\"token attr-value\">org.apache.log4j.ConsoleAppender</span>\n<span class=\"token attr-name\">log4j.appender.console.target</span><span class=\"token punctuation\">=</span><span class=\"token attr-value\">System.err</span>\n<span class=\"token attr-name\">log4j.appender.console.layout</span><span class=\"token punctuation\">=</span><span class=\"token attr-value\">org.apache.log4j.PatternLayout</span>\n<span class=\"token attr-name\">log4j.appender.console.layout.ConversionPattern</span><span class=\"token punctuation\">=</span><span class=\"token attr-value\">%d{ISO8601} [%4p] [%t] %c - %m%n</span>\n\n<span class=\"token attr-name\">log4j.logger.org.apache.hadoop.yarn</span><span class=\"token punctuation\">=</span><span class=\"token attr-value\">WARN</span>\n<span class=\"token attr-name\">log4j.logger.org.apache.spark</span><span class=\"token punctuation\">=</span><span class=\"token attr-value\">WARN</span>\n<span class=\"token attr-name\">log4j.logger.org.apache.spark.jetty</span><span class=\"token punctuation\">=</span><span class=\"token attr-value\">WARN</span></code></pre></div>\n<p>The log4j properties file is used to set the log level (so you can choose if you want to see all debug, info, warn or error messages), and other details about where to log to and with what format. We are only logging Error and Warn messages here and logging everything to the console.</p>\n<p>We could log to a specific file with the following properties.</p>\n<div class=\"gatsby-highlight\" data-language=\"properties\"><pre class=\"language-properties\"><code class=\"language-properties\"><span class=\"token attr-name\">appender.file.type</span> <span class=\"token punctuation\">=</span> <span class=\"token attr-value\">File</span>\n<span class=\"token attr-name\">appender.file.name</span> <span class=\"token punctuation\">=</span> <span class=\"token attr-value\">LOGFILE</span>\n<span class=\"token attr-name\">appender.file.fileName</span><span class=\"token punctuation\">=</span><span class=\"token attr-value\">${filename}/propertieslogs.log</span>\n<span class=\"token attr-name\">appender.file.layout.type</span><span class=\"token punctuation\">=</span><span class=\"token attr-value\">PatternLayout</span></code></pre></div>","headings":[],"frontmatter":{"title":"Logging Setup","toc":null,"experimental":null}},"site":{"siteMetadata":{"title":"Simudyne Docs","latestVersion":"2.6"}}},"pageContext":{"absolutePath":"/home/vsts/work/1/s/content/2.4/reference/logging/logging-setup.md","versioned":true,"version":"2.4","kind":"reference","pagePath":"/reference/logging/logging-setup","chronology":{"prev":{"name":"Logging","path":"/reference/logging"},"next":{"name":"Logging Examples","path":"/reference/logging/logging-examples"}},"lastUpdated":"2026-04-21T13:56:54.852Z"}}