I can't seem to get LogBox to work...like ever... ...
# box-products
a
I can't seem to get LogBox to work...like ever... and I'm certain I'm missing some core concept that is super simple. I have a ColdBox app and I've tried to follow the LogBox documentation at logbox.ortusbooks.com but after I get the config/Coldbox.cfc set up with a logBox configure struct, I can't seem to get a logger working within any of my controllers. I'm willing to pay someone to walk me through the proper config, instantiation, and use of LogBox loggers in a controller and in my model objects because I've spent all day trying to get it to work but I get 500 errors from my server and no details. Would anyone be willing to do a screenshare with me and help me out? simple smile
b
@aaronstoddard Generally speaking, you don't need to instantiate anything. Every ColdBox handler already has a
log
variable injected into it and you can just put
Copy code
<http://log.info|log.info>()
somewhere in your code.
If log messages aren't appearing, chances are your logging levels or logging categories are filtering it out
As a test, start with
Copy code
log.error( 'sdf' )
as that's the most likely severity to get logged and then tail your server's console log
Copy code
# On CommandBox
server log --follow
and look for the message
Without seeing your config or code, it's difficult to guess any further.
a
Thanks Brad, I am able to get the root logger working with the default settings but when I run the app in our QA environment, ColdBox seems to think its production and suddenly nothing is getting logged. Where do I set LogBox to log everything in all environments?
b
I'd check the coldbox.cfc, but again-- not nearly enough information provided here to know what you have configured.
a
Here is my Coldbox.cfc with LogBox default settings.
I've left environments commented out here: I also made sure that there is no .env ENVIRONMENT key in the .env file. but Logbox only logs in localhost.
Is there a default that LogBox will only log in development environments? I don't have any defined in Coldbox.cfc and verified that no .env files exist that specify environments but Logbox won't log in upper environments and I can't figure out why.
b
No, LogBox doesn't have any sort of environment-specific behaviors unless you've configured that
In fact, even ColdBox doesn't have any environment-specific logging configuration unless you've configured that, or used some sort of app template somewhere that configured that, or installed some module that configured that
There is still so much information I would need to help you. Since you're seeing different behaviors on different environments, I'd start by looking at your ColdBox environment override methods if you have any. Again, not part of the information you've shared yet.
It looks like you just have a DBAppender configured. What happens if you turn sync to off? My first guess would be there's an error on the insert, but it's swallowed by the thread
When you put in some manual logging code to debug whether the appender was running, what did you find?
a
I don't believe I have any environment override functions. I commented out the one for development a while back.
I finally figured the problem out. The logging table had the logdate column as timestamp instead of datetime and the insert was throwing an error on the db side. Quick alter and it was writing no problem. Thanks for the help.
👍 1