Coder Social home page Coder Social logo

Comments (2)

suraj-qlogic avatar suraj-qlogic commented on September 27, 2024

@gad2103,Thanks for filling this issue.i am deployed a ktor app on gae standard java11 with logback client and able to successfully log into logging console.For your first question like none of the logs show up. just the message about replayed logs...

Could you try below step and Please let us know if it fixes your issue for above question?

logback.xml

<configuration>
    <appender name="CLOUD" class="com.google.cloud.logging.logback.LoggingAppender">
        <!-- Optional : filter logs at or above a level -->
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <log>application.log</log> <!-- Optional : default java.log -->
        <resourceType>global</resourceType>
        <flushLevel>WARN</flushLevel> <!-- Optional : default ERROR -->
    </appender>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>
    <root level="trace">
        <appender-ref ref="STDOUT"/>
        <!-- Add Cloud Appender to root output-->
        <appender-ref ref="CLOUD" />
    </root>
    <logger name="org.eclipse.jetty" level="INFO"/>
    <logger name="io.netty" level="INFO"/>
</configuration>

Applicaton.kt

package com.test.logback

import io.ktor.application.Application
import io.ktor.application.call
import io.ktor.http.ContentType
import io.ktor.response.respondText
import io.ktor.routing.get
import io.ktor.routing.routing
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
fun main(args: Array<String>): Unit = io.ktor.server.jetty.EngineMain.main(args)

@Suppress("unused") // Referenced in application.conf
@kotlin.jvm.JvmOverloads
fun Application.module(testing: Boolean = false) {
    val logger: Logger = LoggerFactory.getLogger(this::class.java)
    routing {
        get("/") {
            logger.info("This is a test");
            call.respondText("hello world", contentType = ContentType.Text.Plain)
        }
    }
}

Output::
updated-screenshot

from java-logging-logback.

minherz avatar minherz commented on September 27, 2024

I close the issue due to inactivity. Feel free to reopen if you still experience the problem.

from java-logging-logback.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.