Do these instructions still apply to the current release? Is there anything different if running on Windows as a Windows Service?
The OP is out of date. See some of the later posts in the thread or Log4j2 Sample Config.
There is nothing different with the configs when running on Windows.
What exactly do you mean?
The log4j config file is identical when running on all platforms. One does not need to do anything special to make logging work when running on Windows as a service.
I totally broke all openhab logging after I edited the org.ops4j.pax.logging.cfg file. Now nothing is logging at all. I replaced the text of the file with what I found in the org.ops4j.pax.logging.cfg.dpkg-old file but no luck.
I’ve restarted it several times, used the openhabian config tool to install openhabian 2.2 (I believe I was running 2.3 snapshot) because I was under the impression that would reset everything in /var/lib/openhab2 and there for fix it but still no luck.
here is the file as it sits now
# Root logger
log4j.rootLogger = WARN, out, osgi:*
log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer
# openHAB specific logger configuration
log4j.logger.smarthome.event = INFO, event, osgi:*
log4j.logger.smarthome.event.ItemStateEvent = ERROR
log4j.logger.smarthome.event.ItemAddedEvent = ERROR
log4j.logger.smarthome.event.ItemRemovedEvent = ERROR
log4j.logger.smarthome.event.ThingStatusInfoEvent = ERROR
log4j.logger.smarthome.event.InboxUpdatedEvent = ERROR
log4j.additivity.smarthome.event = false
log4j.logger.org.openhab = INFO
log4j.logger.org.eclipse.smarthome = INFO
log4j.logger.org.jupnp = ERROR
log4j.logger.javax.jmdns = ERROR
log4j.logger.org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper = ERROR
log4j.logger.org.apache.karaf.kar.internal.KarServiceImpl = ERROR
log4j.logger.org.apache.aries.spifly = ERROR
# CONSOLE appender not used by default
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n
# File appender - openhab.log
log4j.appender.out=org.apache.log4j.RollingFileAppender
log4j.appender.out.layout=org.apache.log4j.PatternLayout
log4j.appender.out.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n
log4j.appender.out.file=${openhab.logdir}/openhab.log
log4j.appender.out.append=true
log4j.appender.out.maxFileSize=10MB
log4j.appender.out.maxBackupIndex=10
# File appender - events.log
log4j.appender.event=org.apache.log4j.RollingFileAppender
log4j.appender.event.layout=org.apache.log4j.PatternLayout
log4j.appender.event.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-26.26c{1}] - %m%n
log4j.appender.event.file=${openhab.logdir}/events.log
log4j.appender.event.append=true
log4j.appender.event.maxFileSize=10MB
log4j.appender.event.maxBackupIndex=10
# Sift appender
log4j.appender.sift=org.apache.log4j.sift.MDCSiftingAppender
log4j.appender.sift.key=bundle.name
log4j.appender.sift.default=openhab
log4j.appender.sift.appender=org.apache.log4j.FileAppender
log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout
log4j.appender.sift.appender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n
log4j.appender.sift.appender.file=${openhab.logdir}/$\\{bundle.name\\}.log
log4j.appender.sift.appender.append=true
Anyone have any pointers?
Sure enough, that did it. I could have sworn I tried that in my attempts to fix it. Thanks.
Does anyone have any Idea how to get TimeBasedTriggering working?
I replied with my ideas on your original thread. I must have missed it when you first posted.
How do I clear the openhab.log file (not the console log which is explained in the documentation)?
Mine got to 15MB in size during the last install.
Thanks.
rm openhab.log
You just delete it (stop openhab of course before deleting it).
Be aware that it will roll over on its own when the file reaches 16 MB.
Thank you for the reply.
Do I enter
rm openhab.log
That doesn’t work. Or, do I delete the contents of the file manually (or the file)?
Delete the file. But not while OH is running.
But what I was hoping to get across without saying it is:
- 15 MB is nothing to worry about
- OH will move the file to openhab.log.1 when the file reaches 16 MB on its own and after it reaches the 9 it will automatically delete the old log files
- in short, you shouldn’t be worrying about your log files, particularly if you do not have enough experience to be asking these questions in the first place.
I guess I should be looking at console logging for debugging stuff that isn’t working so I’ll leave it alone.
But conversely there are a hell of a lot of posts on here where people are discussing all manner of ways of reducing SD card and USB drive writes to stop corruption including stopping logging all together or logging to an external file server et al.
And they are all focused on moving the logging off of the SD card in the first place. Once the file is written the damage is already done. Deleting a log after it gets (in your opinion) too big does nothing to address this problem. You need to make OH log less, which will buy you maybe a few extra weeks or months before the card dies, or completely move the logging off of the SD card.
Yes, I appreciate that. I do understand the concepts of NAND technology.
What I was trying to do was, as a one-off occasional exercise, reduce the logfile size so, when things were going a bit askew, I wouldn’t have to scroll through pages of old logs to see what had happened that morning, or in the last hour.
Is there a way to exclude dedicated log entries from being created?
For example I have an item CPU_Load which I want to have displayed.
It is updated every second and creates for each item update a log entry. This only spams the log file and I would like to get it out there.
Holger
Hence my link to How to watch and look through logging.
The purpose of the events.log is to log out everything that gets posted to the event bus. So it would be a little counter to the whole purpose of that log file to disable some events. It would give an incomplete picture. Personally, I would either completely turn off events.log rather than prevent it from logging out some events in the first place.
I’ll direct you to the How to watch and look through logging above as well for ways to filter out those lines as you look through the files.
Finally, if you insist, OpenHAB - Filtering event logs will show how to set regular expression filters to prevent the logger from logging out some events.