Reputation: 531
I'm running wildfly as a service on Linux.
I used the well-written instruction on http://developer-should-know.tumblr.com/post/112230363742/how-to-install-wildfly-as-a-service-on-linux that is based on a script [wildflyhome/bin/init.d/wildfly-init-redhat.sh] contained in the wildfly distribution. This script uses the declaration
JBOSS_CONSOLE_LOG="/var/log/wildfly/console.log"
Problem: This configuration logs twice: Firstly in server.log
(in wildflyhome/standalone/log) and secondly in console.log
. This wastes storage (and maybe some performance).
Therefore I set
JBOSS_CONSOLE_LOG="wildflyhome/standalone/log/server.log"
But now each log entry is written twice into server.log -:)
Question: How can I configure wildfly such that it logs just once ?
Upvotes: 5
Views: 4878
Reputation: 1
In the root-logger under domain:logging:3.0 subsystem, Comment out the
<handler name="CONSOLE"/> as below
<!--handler name="CONSOLE"/-->
Afterward, restart your Wildfly Service. The stdout log won't be written to any longer. Hope this helps
Upvotes: 0
Reputation: 111
I had similar problem with Windows Service on Wildfly 11.0.0.Final. Wildfly service created two additional log files. Example:
wildfly-stderr.2017-11-22.log
wildfly-stdout.2017-11-22.log
It saved all logs both to stdout file and to server.log.
I couldn't turn of console-handlers due to Spring Boot logging issues on old version. Instead, i edited service.bat and changed this lines:
if "%STDOUT%"=="" set STDOUT=auto
if "%STDERR%"=="" set STDERR=auto
To this:
if "%STDOUT%"=="" set STDOUT=""
if "%STDERR%"=="" set STDERR=""
It looks that after this logging work correctly(remember to uninstall and install service once again). Now it saves logs only to server.log. I tested this for a while and don't see any missing logs.
Upvotes: 3
Reputation: 1019
Regarding the question whether the service scripts need the consol.log, I would say "yes" the default init.d scripts do need the console handler, because it greps the output to figure out when the service is up and running:
cat /dev/null > "$JBOSS_CONSOLE_LOG"
if [ "$JBOSS_MODE" = "standalone" ]; then
start-stop-daemon --start --user "$JBOSS_USER" \
--chuid "$JBOSS_USER" --chdir "$JBOSS_HOME" --pidfile "$JBOSS_PIDFILE" \
--exec "$JBOSS_SCRIPT" -- -c $JBOSS_CONFIG $JBOSS_OPTS >> "$JBOSS_CONSOLE_LOG" 2>&1 &
else
start-stop-daemon --start --user "$JBOSS_USER" \
--chuid "$JBOSS_USER" --chdir "$JBOSS_HOME" --pidfile "$JBOSS_PIDFILE" \
--exec "$JBOSS_SCRIPT" -- --domain-config=$JBOSS_DOMAIN_CONFIG \
--host-config=$JBOSS_HOST_CONFIG $JBOSS_OPTS >> "$JBOSS_CONSOLE_LOG" 2>&1 &
fi
count=0
launched=0
until [ $count -gt $STARTUP_WAIT ]
do
grep 'JBAS015874:' "$JBOSS_CONSOLE_LOG" > /dev/null
if [ $? -eq 0 ] ; then
launched=1
break
fi
sleep 1
count=$((count + 1));
done
Looking at it, I would say storage is not a major issue, since the script copies /dev/null into the log every time Wildfly starts. And since it greps for a given code 'JBAS015874' to know the server is up, unless you want to delete your entire server.log on every boot, you are going to have to rewrite that bit too (or it will find this string from previous startups!).
So, unless you want to rewrite all the init scripts, I'd just live with it.
Applications should not log to standard out anyways. The only thing I see there after wildfly is up and running are uncaught runtime exceptions...
Upvotes: 1
Reputation: 17780
You can remove the console-handler
from the servers configuration. By default WildFly logs to the stdout and the server.log
. The JBOSS_CONSOLE_LOG="/var/log/wildfly/console.log"
is seeing the output from stdout.
To remove the console handler you can execute the following CLI command
/subsystem=logging/root-logger=ROOT:remove-handler(name=CONSOLE)
If you want you could also remove the console-handler
itself.
/subsystem=logging/console-handler=CONSOLE:remove
Upvotes: 3