java-log4j.json 8.8 KB

123456
  1. {
  2. "html": "<div class=\"section\" id=\"installation\">\n<h2>Installation</h2>\n<p>Using Maven:</p>\n<div class=\"highlight-xml\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span><span style=\"color: #2eb0f7\">&lt;dependency&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;groupId&gt;</span>io.sentry<span style=\"color: #2eb0f7\">&lt;/groupId&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;artifactId&gt;</span>sentry-log4j<span style=\"color: #2eb0f7\">&lt;/artifactId&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;version&gt;</span>1.6.3<span style=\"color: #2eb0f7\">&lt;/version&gt;</span>\n<span style=\"color: #2eb0f7\">&lt;/dependency&gt;</span>\n</pre></div>\n</div>\n<p>Using Gradle:</p>\n<div class=\"highlight-groovy\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span><span style=\"color: #111111\">compile</span> <span style=\"color: #e8535a\">&#39;io.sentry:sentry-log4j:1.6.3&#39;</span>\n</pre></div>\n</div>\n<p>Using SBT:</p>\n<div class=\"highlight-scala\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span><span style=\"color: #111111\">libraryDependencies</span> <span style=\"color: #4b4f5c\">+=</span> <span style=\"color: #e8535a\">&quot;io.sentry&quot;</span> <span style=\"color: #4b4f5c\">%</span> <span style=\"color: #e8535a\">&quot;sentry-log4j&quot;</span> <span style=\"color: #4b4f5c\">%</span> <span style=\"color: #e8535a\">&quot;1.6.3&quot;</span>\n</pre></div>\n</div>\n<p>For other dependency managers see the <a class=\"reference external\" href=\"https://search.maven.org/#artifactdetails%7Cio.sentry%7Csentry-log4j%7C1.6.3%7Cjar\">central Maven repository</a>.</p>\n</div>\n\n\n<div class=\"section\" id=\"usage\">\n<h2>Usage</h2>\n<p>The following examples configure a <code class=\"docutils literal\"><span class=\"pre\">ConsoleAppender</span></code> that logs to standard out\nat the <code class=\"docutils literal\"><span class=\"pre\">INFO</span></code> level and a <code class=\"docutils literal\"><span class=\"pre\">SentryAppender</span></code> that logs to the Sentry server at\nthe <code class=\"docutils literal\"><span class=\"pre\">WARN</span></code> level. The <code class=\"docutils literal\"><span class=\"pre\">ConsoleAppender</span></code> is only provided as an example of\na non-Sentry appender that is set to a different logging threshold, like one you\nmay already have in your project.</p>\n<p>Example configuration using the <code class=\"docutils literal\"><span class=\"pre\">log4j.properties</span></code> format:</p>\n<div class=\"highlight-ini\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span><span style=\"color: #34c08b; font-style: italic\"># Enable the Console and Sentry appenders</span>\n<span style=\"color: #a47ac6\">log4j.rootLogger</span><span style=\"color: #4b4f5c\">=</span><span style=\"color: #e8535a\">INFO, Console, Sentry</span>\n\n<span style=\"color: #34c08b; font-style: italic\"># Configure the Console appender</span>\n<span style=\"color: #a47ac6\">log4j.appender.Console</span><span style=\"color: #4b4f5c\">=</span><span style=\"color: #e8535a\">org.apache.log4j.ConsoleAppender</span>\n<span style=\"color: #a47ac6\">log4j.appender.Console.layout</span><span style=\"color: #4b4f5c\">=</span><span style=\"color: #e8535a\">org.apache.log4j.PatternLayout</span>\n<span style=\"color: #a47ac6\">log4j.appender.Console.layout.ConversionPattern</span><span style=\"color: #4b4f5c\">=</span><span style=\"color: #e8535a\">%d{HH:mm:ss.SSS} [%t] %-5p: %m%n</span>\n\n<span style=\"color: #34c08b; font-style: italic\"># Configure the Sentry appender, overriding the logging threshold to the WARN level</span>\n<span style=\"color: #a47ac6\">log4j.appender.Sentry</span><span style=\"color: #4b4f5c\">=</span><span style=\"color: #e8535a\">io.sentry.log4j.SentryAppender</span>\n<span style=\"color: #a47ac6\">log4j.appender.Sentry.threshold</span><span style=\"color: #4b4f5c\">=</span><span style=\"color: #e8535a\">WARN</span>\n</pre></div>\n</div>\n<p>Alternatively, using the <code class=\"docutils literal\"><span class=\"pre\">log4j.xml</span></code> format:</p>\n<div class=\"highlight-xml\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span><span style=\"color: #34c08b\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;</span>\n<span style=\"color: #34c08b\">&lt;!DOCTYPE log4j:configuration SYSTEM &quot;log4j.dtd&quot;&gt;</span>\n<span style=\"color: #2eb0f7\">&lt;log4j:configuration</span> <span style=\"color: #a47ac6\">debug=</span><span style=\"color: #e8535a\">&quot;true&quot;</span>\n <span style=\"color: #a47ac6\">xmlns:log4j=</span><span style=\"color: #e8535a\">&#39;http://jakarta.apache.org/log4j/&#39;</span><span style=\"color: #2eb0f7\">&gt;</span>\n\n <span style=\"color: #34c08b; font-style: italic\">&lt;!-- Configure the Console appender --&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;appender</span> <span style=\"color: #a47ac6\">name=</span><span style=\"color: #e8535a\">&quot;Console&quot;</span> <span style=\"color: #a47ac6\">class=</span><span style=\"color: #e8535a\">&quot;org.apache.log4j.ConsoleAppender&quot;</span><span style=\"color: #2eb0f7\">&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;layout</span> <span style=\"color: #a47ac6\">class=</span><span style=\"color: #e8535a\">&quot;org.apache.log4j.PatternLayout&quot;</span><span style=\"color: #2eb0f7\">&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;param</span> <span style=\"color: #a47ac6\">name=</span><span style=\"color: #e8535a\">&quot;ConversionPattern&quot;</span>\n <span style=\"color: #a47ac6\">value=</span><span style=\"color: #e8535a\">&quot;%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n&quot;</span> <span style=\"color: #2eb0f7\">/&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;/layout&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;/appender&gt;</span>\n\n <span style=\"color: #34c08b; font-style: italic\">&lt;!-- Configure the Sentry appender, overriding the logging threshold to the WARN level --&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;appender</span> <span style=\"color: #a47ac6\">name=</span><span style=\"color: #e8535a\">&quot;Sentry&quot;</span> <span style=\"color: #a47ac6\">class=</span><span style=\"color: #e8535a\">&quot;io.sentry.log4j.SentryAppender&quot;</span><span style=\"color: #2eb0f7\">&gt;</span>\n <span style=\"color: #34c08b; font-style: italic\">&lt;!-- Override the Sentry handler log level to WARN --&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;filter</span> <span style=\"color: #a47ac6\">class=</span><span style=\"color: #e8535a\">&quot;org.apache.log4j.varia.LevelRangeFilter&quot;</span><span style=\"color: #2eb0f7\">&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;param</span> <span style=\"color: #a47ac6\">name=</span><span style=\"color: #e8535a\">&quot;levelMin&quot;</span> <span style=\"color: #a47ac6\">value=</span><span style=\"color: #e8535a\">&quot;WARN&quot;</span> <span style=\"color: #2eb0f7\">/&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;/filter&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;/appender&gt;</span>\n\n <span style=\"color: #34c08b; font-style: italic\">&lt;!-- Enable the Console and Sentry appenders, Console is provided as an example</span>\n<span style=\"color: #34c08b; font-style: italic\"> of a non-Sentry logger that is set to a different logging threshold --&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;root</span> <span style=\"color: #a47ac6\">level=</span><span style=\"color: #e8535a\">&quot;INFO&quot;</span><span style=\"color: #2eb0f7\">&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;appender-ref</span> <span style=\"color: #a47ac6\">ref=</span><span style=\"color: #e8535a\">&quot;Console&quot;</span> <span style=\"color: #2eb0f7\">/&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;appender-ref</span> <span style=\"color: #a47ac6\">ref=</span><span style=\"color: #e8535a\">&quot;Sentry&quot;</span> <span style=\"color: #2eb0f7\">/&gt;</span>\n <span style=\"color: #2eb0f7\">&lt;/root&gt;</span>\n<span style=\"color: #2eb0f7\">&lt;/log4j:configuration&gt;</span>\n</pre></div>\n</div>\n<p>Next, <strong>you&#8217;ll need to configure your DSN</strong> (client key) and optionally other values such as\n<code class=\"docutils literal\"><span class=\"pre\">environment</span></code> and <code class=\"docutils literal\"><span class=\"pre\">release</span></code>. <a class=\"reference internal\" href=\"https://docs.getsentry.com/clients/java/config/#configuration\"><span>See the configuration page</span></a> for ways you can do this.</p>\n</div>\n",
  3. "link": "https://docs.getsentry.com/clients/java/modules/log4j/",
  4. "id": "java-log4j",
  5. "name": "Log4j 1.x"
  6. }