Comments (6)
Could you elaborate on what logging module you'll remove? I am using JSON logging with openjdk-image right now. I just want to make sure I can continue to use it.
Currently, I'm writing JSON logs to /var/log/app_engine/app-test.json
; it seems to work well. Thank you!
from openjdk-runtime.
@tanin47 we have removed the com.google.cloud.runtimes.logging.JsonFormatter class. Are you using this class directly?
Note that it has already been removed by #38 and this issue should have been closed. Will leave open until we determine if you are using it or not.
from openjdk-runtime.
Ok, I've got it now. And, no, I am not using that class. I'm using net.logstash.logback.encoder.LogstashEncoder
. We are good. Thank you.
from openjdk-runtime.
@tanin47 Can you share your logging configuration for the benefit of others who might want to use it?
from openjdk-runtime.
Definitely! I am using JSON logging with playframework (deployed on this docker image). Here's is my logback.xml
:
<!-- https://www.playframework.com/documentation/latest/SettingsLogger -->
<configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/var/log/app_engine/app-play.json</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>/var/log/app_engine/rolled-app-play-%i.json</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>10</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>5MB</maxFileSize>
</triggeringPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeContext>false</includeContext>
<fieldNames>
<thread>[ignore]</thread>
<levelValue>[ignore]</levelValue>
<logger>logger</logger>
<version>[ignore]</version>
</fieldNames>
</encoder>
</appender>
<logger name="play" level="INFO" />
<logger name="application" level="DEBUG" />
<root level="INFO">
<appender-ref ref="FILE" />
</root>
<shutdownHook/>
</configuration>
Please note that (1) rolling logs, (2) the path of the log file, and (3) encoder are essential.
And, in build.sbt
, we include the below library:
libraryDependencies ++= Seq(
"net.logstash.logback" % "logstash-logback-encoder" % "4.0",
"com.typesafe.scala-logging" %% "scala-logging" % "3.1.0"
)
And, in the code, we can write JSON logs with extra fields as shown below:
import com.typesafe.scalalogging.{Logger => ScalaLogger}
import net.logstash.logback.marker.Markers._
import org.slf4j.Marker
import play.api.{Logger => PlayLogger}
import scala.collection.JavaConversions._
import scala.language.implicitConversions
def getLogger: ScalaLogger = {
ScalaLogger(PlayLogger(new Throwable().getStackTrace()(2).getClassName.stripSuffix("$")).logger)
}
implicit def mapToMapEntriesAppendingMarker[K, V](m: Map[K, V]): Marker = {
append("extras", m: java.util.Map[K, V])
}
object SomeObject {
val logger = getLogger
logger.info(Map("some-field" -> "some-value"), "some-message")
}
from openjdk-runtime.
@tanin47 This is great! Thanks for sharing!
from openjdk-runtime.
Related Issues (20)
- replace uuidgen with more standard tools for deployment token
- Do not build a "builder" image during every image build.
- Local simulation of cloud build fails
- Install OpenJDK 9 from the stretch-backports repository
- Remove `DBG_ENABLE` from README.md HOT 2
- Cloud Debugger doesn't work w/ OpenJDK 9 HOT 11
- Update structure tests to use "Metadata Test" features
- Refactor structure tests to use intermediate container for test scripts
- OpenJDK 10 Runtime HOT 2
- Run OpenJDK Build through Java JCK/TCK HOT 1
- OpenJDK Version Behind for Java 8 HOT 1
- Cannot invoke wget due to libgnutls missing
- Request for supporting Java 10 RunTime HOT 6
- OpenJ9 Runtimes HOT 1
- Graal Runtimes
- TYPO in the readme
- Differences Between Google openjdk Images?
- Profiler Agent Bug HOT 1
- openjdk11 not working HOT 5
- Sample Dockerfile does not work with App Engine - flexible environment
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openjdk-runtime.