123456 |
- {
- "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\"><dependency></span>\n <span style=\"color: #2eb0f7\"><groupId></span>io.sentry<span style=\"color: #2eb0f7\"></groupId></span>\n <span style=\"color: #2eb0f7\"><artifactId></span>sentry-log4j2<span style=\"color: #2eb0f7\"></artifactId></span>\n <span style=\"color: #2eb0f7\"><version></span>1.6.3<span style=\"color: #2eb0f7\"></version></span>\n<span style=\"color: #2eb0f7\"></dependency></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\">'io.sentry:sentry-log4j2:1.6.3'</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\">"io.sentry"</span> <span style=\"color: #4b4f5c\">%</span> <span style=\"color: #e8535a\">"sentry-log4j2"</span> <span style=\"color: #4b4f5c\">%</span> <span style=\"color: #e8535a\">"1.6.3"</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-log4j2%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 example configures 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\">log4j2.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\"><?xml version="1.0" encoding="UTF-8"?></span>\n<span style=\"color: #2eb0f7\"><configuration</span> <span style=\"color: #a47ac6\">status=</span><span style=\"color: #e8535a\">"warn"</span> <span style=\"color: #a47ac6\">packages=</span><span style=\"color: #e8535a\">"org.apache.logging.log4j.core,io.sentry.log4j2"</span><span style=\"color: #2eb0f7\">></span>\n <span style=\"color: #2eb0f7\"><appenders></span>\n <span style=\"color: #2eb0f7\"><Console</span> <span style=\"color: #a47ac6\">name=</span><span style=\"color: #e8535a\">"Console"</span> <span style=\"color: #a47ac6\">target=</span><span style=\"color: #e8535a\">"SYSTEM_OUT"</span><span style=\"color: #2eb0f7\">></span>\n <span style=\"color: #2eb0f7\"><PatternLayout</span> <span style=\"color: #a47ac6\">pattern=</span><span style=\"color: #e8535a\">"%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"</span> <span style=\"color: #2eb0f7\">/></span>\n <span style=\"color: #2eb0f7\"></Console></span>\n\n <span style=\"color: #2eb0f7\"><Sentry</span> <span style=\"color: #a47ac6\">name=</span><span style=\"color: #e8535a\">"Sentry"</span> <span style=\"color: #2eb0f7\">/></span>\n <span style=\"color: #2eb0f7\"></appenders></span>\n\n <span style=\"color: #2eb0f7\"><loggers></span>\n <span style=\"color: #2eb0f7\"><root</span> <span style=\"color: #a47ac6\">level=</span><span style=\"color: #e8535a\">"INFO"</span><span style=\"color: #2eb0f7\">></span>\n <span style=\"color: #2eb0f7\"><appender-ref</span> <span style=\"color: #a47ac6\">ref=</span><span style=\"color: #e8535a\">"Console"</span> <span style=\"color: #2eb0f7\">/></span>\n <span style=\"color: #34c08b; font-style: italic\"><!-- Note that the Sentry logging threshold is overridden to the WARN level --></span>\n <span style=\"color: #2eb0f7\"><appender-ref</span> <span style=\"color: #a47ac6\">ref=</span><span style=\"color: #e8535a\">"Sentry"</span> <span style=\"color: #a47ac6\">level=</span><span style=\"color: #e8535a\">"WARN"</span> <span style=\"color: #2eb0f7\">/></span>\n <span style=\"color: #2eb0f7\"></root></span>\n <span style=\"color: #2eb0f7\"></loggers></span>\n<span style=\"color: #2eb0f7\"></configuration></span>\n</pre></div>\n</div>\n<p>Next, <strong>you’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",
- "link": "https://docs.getsentry.com/clients/java/modules/log4j2/",
- "id": "java-log4j2",
- "name": "Log4j 2.x"
- }
|