can someone help me with a little question?
I made some loggers which log to extra files. However, I have now noticed that these loggers are not displayed in the console when I run the log:display command. Is it possible for loggers to write to extra files but still show up in the console? Attached is the log4j2.xml with the loggers I created and are working so far. log4j2.xml.txt (9.6 KB)
- Platform information:
- Hardware: Raspberry Pi 4, 8 GB RAM
- OS: Raspberry Pi OS 10 (Buster)
- Java Runtime Environment:
openjdk 11.0.11 2021-04-20 LTS
OpenJDK Runtime Environment Zulu11.48+21-CA (build 11.0.11+9-LTS)
OpenJDK Client VM Zulu11.48+21-CA (build 11.0.11+9-LTS, mixed mode)
- openHAB version: openHAB 3.2.0 Release Build
Thank you in advance for the support.
Adding the related log level for your scripts will add the output to the console as well.
sorry but I don’t understand your answer. As written in my first post, I created new loggers using log4j2.xml, which log in extra files. See the file attached to my first post. After restarting the openhab service, these extra files were also created automatically. I then used these loggers in small rules.
Here is the content of an example rules file:
rule "Logtest EIN"
Item TestItemLogging changed to ON
logInfo("EXTRA","Test extra.log EIN")
rule "Logtest AUS"
Item TestItemLogging changed to OFF
logInfo("EXTRA","Test extra.log AUS")
If TestItemLogging changes, the corresponding information is also written to the respective log file:
2022-04-26 11:14:18.707 [INFO ] [org.openhab.core.model.script.EXTRA ] - Test extra.log EIN
2022-04-26 11:14:25.913 [INFO ] [org.openhab.core.model.script.EXTRA ] - Test extra.log AUS
I thought I defined the loglevel with the “logInfo” command in my rules. I only want to see the LogInfo output in addition to the log files in the console, and that permanently.
But unfortunately the output in the console remains empty.
openhab> log:display org.openhab.core.model.script.EXTRA
When I run log:list in the console, I also see my scripts in the list, with each configured level:
Logger │ Level
ROOT │ WARN
javax.jmdns │ ERROR
javax.mail │ ERROR
openhab.event │ INFO
openhab.event.AddonEvent │ ERROR
openhab.event.ChannelDescriptionChangedEvent │ ERROR
openhab.event.InboxUpdatedEvent │ ERROR
openhab.event.ItemAddedEvent │ ERROR
openhab.event.ItemChannelLinkAddedEvent │ ERROR
openhab.event.ItemChannelLinkRemovedEvent │ ERROR
openhab.event.ItemRemovedEvent │ ERROR
openhab.event.ItemStateEvent │ ERROR
openhab.event.RuleAddedEvent │ ERROR
openhab.event.RuleRemovedEvent │ ERROR
openhab.event.RuleStatusInfoEvent │ ERROR
openhab.event.StartlevelEvent │ ERROR
openhab.event.ThingAddedEvent │ ERROR
openhab.event.ThingRemovedEvent │ ERROR
openhab.event.ThingStatusInfoEvent │ ERROR
openhab.event.ThingUpdatedEvent │ ERROR
org.apache.cxf.jaxrs.sse.SseEventSinkImpl │ ERROR
org.apache.karaf.jaas.modules.audit │ INFO
org.apache.karaf.kar.internal.KarServiceImpl │ ERROR
org.apache.karaf.shell.ssh.SshUtils │ ERROR
org.apache.karaf.shell.support │ OFF
org.apache.sshd │ ERROR
org.eclipse.lsp4j │ OFF
org.jupnp │ ERROR
org.openhab │ INFO
org.openhab.automation.script │ TRACE
org.openhab.core.model.script.BATTERIERAUM │ INFO
org.openhab.core.model.script.BEWAESSERUNG │ INFO
org.openhab.core.model.script.EXTRA │ INFO
org.openhab.core.model.script.HEATING │ INFO
org.openhab.core.model.script.ROHRREINIGUNG │ INFO
org.openhab.core.model.script.RUECKSTAUKLAPPE │ INFO
org.openhab.core.model.script.ZISTERNE │ INFO
org.ops4j.pax.url.mvn.internal.AetherBasedResolver │ ERROR
org.ops4j.pax.web.pax-web-runtime │ OFF
su.litvak.chromecast.api.v2.Channel │ ERROR
At what point do I have to configure the log level so that the same content from the extra files is always output in the console?
Many thanks and greetings
prevents that the log message is forwarded to another logger. Thus the console logger will not receive it. Try to change it to “true” in the configuration of your additional loggers, that should yield the desired result.
Thank you for your reply. That was the trick. Now it works!
A small further question, how long are the log entries visible under log:display? I noticed that these are no longer displayed after a short time. Is it possible to extend the display in log:display?
That I can’t answer, sorry. Hopefully someone else can step in.
I want to bring up this thread again because I still haven’t gotten anywhere. In the meantime I have also created a logger that writes to the standard log openhab.log. My current problem is that the log entries of these loggers are only displayed in the console for about 5 minutes. If I call log:display several times within this 5 minutes, I can see that the entries disappear after 5 minutes. Is there a way to increase this display for this logger to, for example, 48 hours?
Thank you very much for your effort.
other entries are shown for a longer time ?
Just did a test here and I see that about ~500 rows are kept in the “buffer” of log:display.
The oldest entry is nearly 1.5h old.
So I am thinking of if in your case there is a bigger amount of entries that are being logged and this may be why they are not kept that long ?