I am using ConsoleAppender
for logging in my Java application.
ConsoleAppender
writes to the System.out
which is stdout
in case of Linux.
Can someone help me understanding where does stdout
logs go and how much is the memory assigned to it.
I need to know this because all my logs to stdout
are not being picked by filebeat to put in the elastic search index.
Can someone help me understanding where does stdout logs go
Usually stdout
simply goes into the buffer of your shell which is usually not buffered/recorded to any file. I say usually because I am sure that there are some special systems & Linux distributions that can handle things differently.
For the rest, I assume that you use a "common Linux desktop or server distribution."
However, what you can do is redirecting stdout
to a file.
I assume that you launch your application similar to this:
java -jar myapp.jar
Your application outputs to stdout
which allows you to see the output in the terminal.
On Linux (I'd say most Unix systems), you can simply redirect the stdout
(and optionally stderr
) to a file like this:
java -jar myapp.jar > output.txt
A file named output.txt
should then be created on your system.
If you still need "real time user feedback" you can simply do something like
tail -f output.txt
to continiously print the contents of output.txt
to stdout
.
how much is the memory assigned to it.
Your output.txt
file will grow until you run out of disk space. You can use your distributions log rotation system to limit the size of the file. FreeBSD uses newlogsys(8). I am sure that the Linux distribution of your choice comes with a similar system already in place.