Guide a daemon process output to console stdout or stderr - stdout

I've a daemon process periodically output the info to log file, how can i get these info output to console stdout or stderr?
Thank you in advance.

Related

How can Splunk distinguish between output to stdout and stderr in Docker context?

We have a Java application that can be run in Docker containers. It produces messages to stdout and stderr with a different level of detail for different audiences.
Configuring Splunk as log driver all log lines received by Splunk a marked with source stdout although there must be log lines being logged to stderr.
Splunk log driver configuration in docker-compose:
logging:
driver: splunk
options:
splunk-url: https://splunkhf:8088
splunk-token: [TOKEN]
splunk-index: splunk_index
splunk-insecureskipverify: "true"
splunk-sourcetype: log4j
splunk-format: "json"
tag: "{{.Name}}/{{.ID}}"
Example log message sent to splunk:
{
line: 2021-01-12 11:37:49,191;10718;INFO ;[Thread-1];Logger; ;Executed all shutdown events.
source: stdout
tag: service_95f2bac29286/582385192fde
}
How can I configure Docker or Splunk to differentiate correctly between those different streams?`
If you run the service from docker-compose without -d then the logs lose their original source. It seems that Docker and Docker-Compose put everything from the container's output streams to stdout and use stderr for their logs.
Using the -d flag the log messages do not lose their original output stream.

Understanding supervisord logging; stdout only displaying stderr messages

I have a very simple python program I am running in supervisord.
The supervisord.conf is completely default besides the program section:
[program:logwatcher]
command=/path/to/python -u "/path/to/logwatcher.py"
The python code:
import sys
print("print\n")
print("file=sys.stdout\n", file=sys.stdout)
print("file=sys.stderr\n", file=sys.stderr)
sys.stdout.write("sys.stdout.write\n")
sys.stderr.write("sys.stderr.write\n")
Produces this output:
supervisor> tail logwatcher
print
file=sys.stdout
sys.stdout.write
supervisor> tail logwatcher stdout
file=sys.stderr
sys.stderr.write
supervisor> tail logwatcher stderr
file=sys.stderr
sys.stderr.write
why is tail stdout only showing stderr messages, and not stdout messages?
why is tail stdout showing stderr at all?
if tail is supposed to mimic tail stdout why don't they match?
tested on supervisor 3.3.5 and supervisor 4.0.1

Redirect docker logs to file

Normally when I redirect my docker log to a text file, all the content will store in the output file.
This is what I expected outcome
[root#ip-xx-xx-xx-xx ~]$ docker logs aa46e7139ce5 > docker.log
[root#ip-xx-xx-xx-xx ~]$
But sometimes the output will become following and the errors are not included in the docker.log
[root#ip-xx-xx-xx-xx ~]$ docker logs aaasdas9c356 > docker.log
Debugger failed to attach: handshake failed - received >GET / HTTP/1.0 < - expected >JDWP-Handshake<
Debugger failed to attach: recv failed during handshake: Resource temporarily unavailable
Debugger failed to attach: received >< - expected >JDWP-Handshake<
[root#ip-xx-xx-xx-xx ~]$
Just wondering why the output will have different behaviour.
Thanks
You're missing stderr. The output redirect handles file descriptor 1, stdout. For messages sent to stderr on file descriptor 2, you need to redirect that separately. Either to the same location:
docker logs aaasdas9c356 > docker.log 2>&1
Or to a separate file:
docker logs aaasdas9c356 > docker.log 2>docker.err

What is the stdout output?

Newbie; I'm learning the Linux cmd line and one of my questions is; "inside the ‘stream-redirection’ folder there is a program called ‘program’. When you run this it will output to stdout and stderr. What is the stdout output??? I'm unsure how to read the output and even where it is??
I've tried
./program 1> stdout then cat stdout
I'm lost and I have to do the same with stderr.

netstate -lput doesn't show the pid of deamon that is listening on port:8080?

I runed:netstat -lputn to find ount which program is listening on port 8080,but got blow output:
As you can see no pid or program name got shown,why?
I found it:
ps -ef|grep 8080
It turns out jenkins

Resources