https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
ktor
  • a

    Ayodele

    06/30/2020, 10:19 AM
    Hii guys so I'm working on a microservice I'm using httpclient to plug into the UberApi and I'm getting results in the desired route in the localhost Now i need to plug it to my ktorservice so I can use a Post request from the Android end and get desired results on mobile client
    h
    r
    +1
    156 replies · 4 participants
  • s

    Stefan Peterson

    06/30/2020, 11:39 PM
    Pretty noob ktor user here. I am trying to set up logging for our production environment to be
    INFO
    level. For a Logback provider I have
    logback-classic
    declared as a dependency in my
    pom.xml
    and set up a
    logback.xml
    file src > main > resources but when I try to access the default logger in any ApplicationCall context I am still seeing
    DEBUG
    level logs. My
    logback.xml
    looks like the following:
    <configuration>
        <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="info">
            <appender-ref ref="STDOUT"/>
        </root>
    
        <logger name="org.eclipse.jetty" level="INFO"/>
        <logger name="io.netty" level="INFO"/>
        <logger name="ktor.application" level="INFO" />
    </configuration>
    l
    1 reply · 2 participants
  • g

    Gunslingor

    07/01/2020, 5:16 AM
    Anyone know where I can find good documentation on deploying ktor and a Mysql database on AWS via build pipeline? making progress but its bumpy.
    a
    10 replies · 2 participants
  • d

    darkmoon_uk

    07/01/2020, 1:19 PM
    There's a
    ktor-auth-kotlinMultiplatform
    package in version
    1.3.1
    so I took it's disappearance from
    1.3.2
    to mean the MPP metadata became included as standard for
    ktor-auth
    itself... no?
    g
    7 replies · 2 participants
  • s

    Shawn Karber_

    07/01/2020, 4:34 PM
    I am trying to get the example code to work listed here: Json - Clients - Ktor , notable:
    val client = HttpClient(HttpClientEngine) {
        install(JsonFeature) {
            serializer = GsonSerializer()
        }
    }
    but theres an issue with
    HttpClient(HttpClientEngine)
    The error says
    HttpClientEngine
    does not have a companion object, thus must be initialized here, what am I doing wrong?
    i
    6 replies · 2 participants
  • n

    Nikolaj

    07/02/2020, 8:05 AM
    Hi, does someone try to run graalvm native compilation on ktor ? I manage to get compiled with Netty but failed to start .. with awkward exceptions
    r
    1 reply · 2 participants
  • o

    Osmium

    07/02/2020, 10:47 AM
    hello everyone! has anyone here tried to implement providing ApplicationCall via custom DI (i.e. Koin)? I'm struggling with
    ThreadLocal.asContextElement
    and stuff (i'm bad at coroutines, to be honest), and i'm curious if someone already implemented that...
    2 replies · 1 participant
  • l

    LastExceed

    07/02/2020, 11:41 AM
    getting postA works fine, getting postB gives
    java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class Post
    . It seems T is getting erased despite being reified. why is that ?
    Untitled
    👀 1
    r
    s
    4 replies · 3 participants
  • m

    manlan

    07/03/2020, 6:32 AM
    Hello folks! How do I handle API keys in Ktor? Where do I put and access them safely?
    👀 2
    s
    7 replies · 2 participants
  • a

    agta1991

    07/03/2020, 8:50 AM
    Hi folks! I'm experimenting with ktor in a multi-module multiplatform mobile app, but if I try to use ktor in any of the submodules I get a strange error from Gradle, like this:
    3 replies · 1 participant
  • g

    Gunslingor

    07/03/2020, 10:35 PM
    Anyone know what I'm doing wrong here, trying to capture the output from the command, always gettiung the stream id instead of the stream no matter what I try. Ultimately trying to spin up local docker image after build but presently just trying to run basic commands so I know that part is working:
    register<Exec>("runFatJarLocallyInDocker") {
        group = "application"
        dependsOn(mutableSetOf<Any>("buildFatJar"))
        commandLine = mutableListOf("cmd", "dir")
        val std = standardOutput
        doLast {
            println()
            println("Output: ${std.toString()}")
            println("Error: ${errorOutput.toString()}")
        }
    
        /*
        commandLine(
            "docker dir",
            "docker build -t ${project.name}-fat.jar",
            "docker run -m512M --cpus 2 -it -p 8080:8080 --rm ${project.name}-fat.jar"
        )*/
    }
    1 reply · 1 participant
  • k

    Kepha

    07/06/2020, 1:34 AM
    Can I make blocking proxy for blacklist ip based on KOTR ?
    1 reply · 1 participant
  • k

    Kepha

    07/06/2020, 1:45 AM
    KTOR DefaultWebSocketSession.terminate() is deprecated like this:
    /**
     * Initiate connection termination immediately. Termination may complete asynchronously.
     */
    @Deprecated(
        "Use cancel() instead.",
        ReplaceWith("cancel()", "kotlinx.coroutines.cancel")
    )
    actual fun terminate()
    What is the difference between terminate() and cancel() ?
    g
    2 replies · 2 participants
  • r

    Rodrigo Silva

    07/06/2020, 11:37 AM
    Hi all. Does Ktor have something similar to Spring Webclient?
    a
    6 replies · 2 participants
  • s

    Shawn A

    07/06/2020, 4:00 PM
    How does one handle custom config binding from the app's HOCON? I've read the configuration docs but its not quite clear if/how I can bind arbitrary config values to, for instance a data class.
    👀 1
    m
    w
    4 replies · 3 participants
  • r

    Rachid

    07/06/2020, 7:54 PM
    I moved my WebSocket client from JS to the common source set. I see no "compile errors" in IntelliJ, but when building I see messages like:
    Error:(3, 23) Kotlin: Unresolved reference: HttpClient
    When I CMD+click on that import it jumps to the "ktor-client-core" external lib. Yesterday I somehow fiddled enough to get rid of this error, but today it popped up again. Now I can't start the JVM process anymore. In Gradle for both JVM as common I have these deps:
    implementation "io.ktor:ktor-client-core:$ktor_version"
    implementation "io.ktor:ktor-client-websockets:$ktor_version"
    Any idea what's wrong here?
    1 reply · 1 participant
  • g

    Gunslingor

    07/07/2020, 2:54 AM
    Could use a hand, does any one know why buildFatJar seems to build the jar correctly but then it never runs, saying it can't find the main class, however runLocally runs fine locally? I'd prefer not to use shadow... my experience with gradle, if there is one thing I've learned, mixing plugins is futile and a brain murderer.
    register<Jar>("buildFatJar") {
        group = "application"
        manifest {
            attributes["Implementation-Title"] = "Gradle Jar File Example"
            attributes["Implementation-Version"] = archiveVersion
            attributes["Main-Class"] = "com.app.BackendAppKt"
        }
        archiveBaseName.set("${project.name}-fat")
        from(main.output.classesDirs, main.compileDependencyFiles)
        with(jar.get() as CopySpec)
    }
    register<JavaExec>("runLocally") {
        group = "application"
        setMain("com.app.BackendAppKt")
        classpath = main.output.classesDirs
        classpath += main.compileDependencyFiles
    }
    f
    c
    3 replies · 3 participants
  • b

    bbaldino

    07/07/2020, 10:06 PM
    I've got an API client class which creates an
    HttpClient
    and I want to add a hook so I can pass a
    MockEngine
    in for unit testing, but running into a few issues: My first thought was to have the entire client be a ctor param and default it to what I want, i.e.:
    class MyClass(
        private val client: HttpClient = HttpClient(Apache) {
            install(JsonFeature) { ... }
        }
    ) {
    but then if I pass in a mock client,
    MyClass
    won't install the JsonFeature, so next I thought about passing in the engine:
    class MyClass(
        private val clientEngine: HttpClientEngine = Apache
    ) {
    but this doesn't work because
    Apache
    isn't an
    HttpClientEngine
    , it's an
    HttpClientEngineFactory
    . And I don't want to change the ctor to take in a
    HttpClientEngineFactory
    because it has a generic type and I don't want to add a generic to the class just to support this. I'm assuming there must be something simple here I'm missing?
    5 replies · 1 participant
  • l

    Luis Munoz

    07/08/2020, 2:18 AM
    Trying to use swagger option on https://ktor.io/quickstart/generator.html I get IllegalStateException: Not a JSON or YAML file. I know that it is valid yaml because it has been validated. Should I file an issue?
    2 replies · 1 participant
  • c

    codec

    07/08/2020, 3:04 AM
    Does Ktor have a “Push API”? I want clients to automatically receive new data, even if it didn’t originate in their session.
    k
    5 replies · 2 participants
  • l

    Luis Munoz

    07/08/2020, 4:02 AM
    Why do I get 404 when trying to serve a js file using:
    val staticDir = "rest-api/static"
            static("/") {
                staticRootFolder = File(staticDir)
                files("js")
                default("index.html")
            }
    3 replies · 1 participant
  • d

    Dominic Michel

    07/08/2020, 6:43 AM
    Hey. I'm using the ktor http client and i'm wondering if it can be configured to not throw an exception if the request fails with status 40x. I know about
    HttpClient {
      expectSuccess = false
    }
    but if set, the exception just changes from
    ClientRequestException
    to
    IllegalStateException
    Can the throwing of exceptions somehow be prevented completely or do i have to resort to a try/catch block?
    a
    g
    3 replies · 3 participants
  • s

    Sean Najera

    07/08/2020, 6:29 PM
    I just created a kotlin multiplatform library for android, ios and Javascript which uses the Ktor client for all three. These are my dependencies for the javascript library
    // MPP - JS & common dependencies
    
        sourceSets["commonMain"].dependencies {
            implementation(kotlin("stdlib-common", Versions.KOTLIN))
            implementation(Deps.Ktor.COMMON_CORE)
            implementation(Deps.Ktor.COMMON_JSON)
            implementation(Deps.Coroutines.COMMON)
            implementation(Deps.MP_SETTINGS)
            implementation(Deps.Ktor.COMMON_SERIALIZER)
            implementation(Deps.Serialization.COMMON)
            implementation(Deps.Stately.COMMON)
            implementation(Deps.Stately.CONCURRENCY)
        }    
    
        sourceSets["jsMain"].dependencies {
            implementation((kotlin("stdlib-js", Versions.KOTLIN)))
            implementation(Deps.Ktor.JS_CORE)
            implementation(Deps.Ktor.JS_JSON)
            implementation(Deps.Coroutines.JS)
            implementation(Deps.Ktor.JS_SERIALIZER)
            implementation(Deps.Serialization.JS)
        }
    
    
    // Front-End react app dependencies
        implementation(kotlin("stdlib-js"))
    
        //React, React DOM + Wrappers (chapter 3)
        implementation("org.jetbrains:kotlin-react:16.13.0-pre.94-kotlin-1.3.70")
        implementation("org.jetbrains:kotlin-react-dom:16.13.0-pre.94-kotlin-1.3.70")
        implementation(npm("react", "16.13.1"))
        implementation(npm("react-dom", "16.13.1"))
    
        //Kotlin Styled (chapter 3)
        implementation("org.jetbrains:kotlin-styled:1.0.0-pre.94-kotlin-1.3.70")
        implementation(npm("styled-components"))
        implementation(npm("inline-style-prefixer"))
    
        //Video Player (chapter 7)
        implementation(npm("react-player"))
    
        //Share Buttons (chapter 7)
        implementation(npm("react-share"))
    
        // Shared Library: Nautilus
        implementation(project(":MarianaKit"))
    
        //Coroutines (chapter 8)
        implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.7")
    When I import the javascript library into the Jetbrains starter React app, the dev distribution size 27MiB and the production distribution size is 1.5 MiB. Is anyone else having such large distribution sizes? Is this normal? Or am I doing something on my end to cause this?
    j
    8 replies · 2 participants
  • j

    janvladimirmostert

    07/08/2020, 7:17 PM
    i noticed in the docs that having watchPaths turned on for production leads to a performance penalty, i'm assuming giving it an empty list will mitigate this performance penalty?
    embeddedServer(
    			CIO,
    			module = Application::module,
    			port = if (ENV.env == LOCAL) {
    				7777
    			} else {
    				80
    			},
    			watchPaths = if (ENV.env == LOCAL) {
    				listOf("build")
    			} else {
    				listOf()
    			}
    		).apply {
    			start(wait = true)
    		}
    w
    1 reply · 2 participants
  • b

    bbaldino

    07/09/2020, 5:46 PM
    Is there a good pattern to define the application module inside of a class? We use a qualified class name for our loggers, so having just the standalone extension function is a bit awkward. I've done something like this:
    class MyClass {
        val module: Application.() -> Unit {
            ...
        }
    }
    and then it's installed/started via something like:
    val myClass = MyClass()
    embeddedServer(Jetty) {
        myClass.module(this)
    }
    which isn't bad, but wondering if there's a better/more idiomatic way?
    n
    11 replies · 2 participants
  • m

    Matt Kranzler

    07/10/2020, 2:24 PM
    I'm having a strange issue which I believe is possibly a bug in ktor but I'm struggling to figure out what could be happening. I have a local http server running a spring boot rest api and I'm attempting to make a series of http requests via the Android emulator using ktor in a shared common module. The requests look like this:
    POST -> <http://10.0.2.2:8080/account/login>
    GET -> <http://10.0.2.2:8080/user/me>
    POST -> <http://10.0.2.2:8080/user/devices>
    The first two requests succeed but the third request is returning a 500 from my server with the following error:
    org.springframework.security.web.firewall.RequestRejectedException: The request was rejected because the HTTP method "ST" was not included within the whitelist [HEAD, DELETE, POST, GET, OPTIONS, PATCH, PUT]
    I've debugged the earliest entry point on the server side and verified the HTTP method is coming in as
    ST
    . I've also enabled tomcat access logging and verified the request comes in with an HTTP method of
    ST
    . On the Android/multiplatform side the ktor logging show the last request as a
    POST
    and the Android Studio network profiler show the request as a
    POST
    . What's even more weird is if I change the order of the requests to this:
    POST -> <http://10.0.2.2:8080/account/login>
    POST -> <http://10.0.2.2:8080/user/devices>
    GET -> <http://10.0.2.2:8080/user/me>
    it works fine and comes through as a
    POST
    on the server side. What makes this even more difficult to track down is that I'm unable to debug on the client side because as soon as I run with the debugger or attach the debugger Android Studio and Intellij both lock up completely and I have to force quit. Does anyone have any ideas on what could be happening or any suggestions on what else to try?
    n
    8 replies · 2 participants
  • t

    torres

    07/10/2020, 2:47 PM
    any advice how to fix this error?
    Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    ..
    at io.ktor.server.netty.NettyApplicationEngine.start(NettyApplicationEngine.kt:126)
    at io.ktor.server.netty.EngineMain.main(EngineMain.kt:26)
    at com.example.ApplicationKt.main(Application.kt:11)
    Caused by: <http://java.net|java.net>.ConnectException: Connection refused
    at <http://sun.nio.ch|sun.nio.ch>.SocketChannelImpl.checkConnect(Native Method)
    at <http://sun.nio.ch|sun.nio.ch>.SocketChannelImpl.finishConnect(SocketChannelImpl.java:714)
    at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:174)
    at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:148)
    at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351)
    at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221)
    at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
    at java.lang.Thread.run(Thread.java:821)
    ✅ 1
    v
    8 replies · 2 participants
  • g

    Gus

    07/12/2020, 2:23 PM
    Hello. How do you test a WebSocket client? It doesn't seem like I can use
    handleWebSocketConversation
    or anything related to WebSocket inside `addHandler`:
    val ktorClient = HttpClient(MockEngine) {
                    engine {
                        addHandler { request ->
                            handleWebSocketConversation {}
                        }
                    }
                }
    b
    1 reply · 2 participants
  • p

    pmiklos

    07/12/2020, 8:12 PM
    Hi, I am trying to use the HttpClient with WebSockets in a multiplatform project but on linux native I get
    [generateNonce] is not supported on iOS
    coming from the WebSocketContent constructor. I found that there is no implementation for
    generateNonce
    in the ktor-utils native library. It's kind of weird it says iOS when the targe platform is linux. Are websockets supposed to work on native linux platform?
    n
    2 replies · 2 participants
  • j

    Jeff

    07/13/2020, 1:54 PM
    Hello, My client doesn't print logs when I make requests through my Android app. Any help would be appreciated. I only get to see:
    I/System.out: [OkHttp] sendRequest>>
    The code is as follows:
    private val client by lazy {
            HttpClient {
                install(JsonFeature) {
                    serializer = KotlinxSerializer(
                        Json(
                            JsonConfiguration(
                                isLenient = true,
                                ignoreUnknownKeys = true
                            )
                        )
                    )
                }
                install(Logging) {
                    logger = Logger.DEFAULT
                    level = LogLevel.ALL
                }
            }
        }
    z
    r
    3 replies · 3 participants
Powered by Linen
Title
j

Jeff

07/13/2020, 1:54 PM
Hello, My client doesn't print logs when I make requests through my Android app. Any help would be appreciated. I only get to see:
I/System.out: [OkHttp] sendRequest>>
The code is as follows:
private val client by lazy {
        HttpClient {
            install(JsonFeature) {
                serializer = KotlinxSerializer(
                    Json(
                        JsonConfiguration(
                            isLenient = true,
                            ignoreUnknownKeys = true
                        )
                    )
                )
            }
            install(Logging) {
                logger = Logger.DEFAULT
                level = LogLevel.ALL
            }
        }
    }
z

zalewski.se

07/14/2020, 2:35 AM
Try with
logger = Logger.SIMPLE
r

ritesh

07/14/2020, 7:23 AM
also you can also make you own logger,
logger = MyLogger
...
object MyLogger: Logger {
    override fun log(message: String) {
        // log event like println or something else you want
    }
}
j

Jeff

07/14/2020, 7:42 AM
Thanks guys
View count: 2