Log file not getting created

I am trying to publish all my logs to a file besides to standard output. For this I created a logback.xml under resources directory adding file appender as per suggestion here.

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <file>${application.home:-.}/logs/application.log</file>
    <encoder>
        <pattern>%date [%level] from %logger in %thread - %message%n%xException</pattern>
    </encoder>
</appender>

But it is failing to create a log file in the container working directory:

demiourgos728@ca5fc4a4c1db:/opt/docker$ ls
bin  lib  share

My docker base images conf: dockerBaseImage := "adoptopenjdk/openjdk8"

I am not sure what is really going wrong here. Please suggest.

I have explained this question in detail at stackoverflow too.

@aklikic @ihostage Could you please help me out with this one?

Hi @codingkapoor,

from your log file

java.io.FileNotFoundException: ./logs/application.log (No such file or directory)

you can conclude that

application.home

in

${application.home:-.}

is not set and “.” is used.
You can set it via JAVA_OPTS in your deployment yaml:

-Dapplication.home=#location#

But why do you want to write in a file?
When you save to a file it will be stored in the file in the docker container itself.
In case of stdout, stdout will be collected by the docker and stored in the file on the node itself (/var/log/containers/). From there it can be collected by a log aggregation tooling (like fluentbit).

Hope this helps.

Br,
Alan

1 Like

Understood. Many thanks!