danlance
06/07/2023, 12:19 PM"WARN","XNIO-1 task-17","06/07/2023","12:31:57","cftrace","[1686137517872 ms (1st trace)] [/usr/local/lib/serverHome/WEB-INF/lucee-web/components/org/lucee/cfml/Query.cfc @ line: 30]- [arguments.sql=""{EXAMPLE SQL}""] "
This does not appear to be every trace which is logged - however it is significant enough for us to see over 2.47 Million requests logged in the last 4 weeks on one of the busier applications we host!
Can anyone advise what we can do stop this being logged?
Also - 1686137517872 ms which this query has been logged as taking, equates to ~53.5 years… which is quite impressive… I hadn’t realised our application had been running that long! (or that Lucee was that old… or AWS… or the internet in general really!!!)
Digging into the code for the cfquery tag,I did find the following lines - but they appear to be in a different format, and appear to be referring to and writing to datasource.log
https://github.com/lucee/Lucee/blob/5.3.10.120/core/src/main/java/lucee/runtime/tag/Query.java#L778-L782
datasource.log???
Well, that’s not something which we have configured within log shipping for our production environments - as this was not a file which Lucee produced by default at the time we initially configured our log shipping with an earlier version of lucee (probably 1 5.1 variant)
So I fired up a new local instance of the application, and then checked the lucee web logs folder… and… 82,000 log file lines just from starting the app and hitting a few pages.
This does indeed appear to be logging every single SQL request to to the datasource log file.
Looking at the the following logic from Lucee’s Query.java:
Log log = ThreadLocalPageContext.getLog(pageContext, "datasource");
if (log.getLogLevel() >= Log.LEVEL_INFO) {
<http://log.info|log.info>("query tag", "executed [" + sqlQuery.toString().trim() + "] in " + DecimalFormat.call(pageContext, exe / 1000000D) + " ms");
}
Ok, so If I read this correctly…
It appears that
• Lucee is retrieving the log object for datasource.log
• Lucee is comparing the configured logLevel for datasource.log to Log.LEVEL_INFO and if datasource.log logLevel is higher than Info, then write the query to the datasource.log file
Ok - so, next I look at the implementation of the Log interface to see how the log levels would be compared:
https://github.com/lucee/Lucee/blob/5.3.10.120/loader/src/main/java/lucee/commons/io/log/Log.java#L24-L46
Ok - so, LEVEL_INFO = 1;
So if the datasource.log log level is set to anything other than LEVEL_TRACE then every SQL statement needs to be logged to datasource.log??????? 🤦
So - please tell me, am I interpreting that correctly?
If datasource.log is configured to LEVEL_TRACE then nothing will be logged, but if it’s configured to LEVEL_INFO / LEVEL_DEBUG / LEVEL_WARN / LEVEL_ERROR / LEVEL_FATAL then nothing will be logged???
If that’s correct, then isn’t that the wrong way round - if we set a log level to LEVEL_WARN - doesn’t that mean “only log entries to the file which are of LEVEL_WARN or above?” I.e. the higher the value, the less should be logged?
It feels like there is a bug with the logic here… and the condition has been reversed. Can I just get confirmation that my understanding (not being primarily a java developer) is correct here?
I suspect that a similar logic error may be responsible for the copious (all though not as extensive) logging to the trace.log - but haven’t identified the specific location where that takes place… if anyone can enlighten me, that would be appreciated.zackster
06/07/2023, 12:21 PMzackster
06/07/2023, 12:24 PMdanlance
06/07/2023, 12:26 PMzackster
06/07/2023, 12:28 PMzackster
06/07/2023, 12:29 PMzackster
06/07/2023, 12:29 PMzackster
06/07/2023, 12:29 PMdanlance
06/07/2023, 12:31 PMdanlance
06/07/2023, 12:31 PMzackster
06/07/2023, 12:40 PMzackster
06/07/2023, 12:41 PMzackster
06/07/2023, 12:43 PMzackster
06/07/2023, 12:43 PMzackster
06/07/2023, 12:45 PMzackster
06/07/2023, 12:46 PMdanlance
06/07/2023, 12:47 PMzackster
06/07/2023, 12:47 PMdanlance
06/07/2023, 12:50 PMzackster
06/07/2023, 12:50 PMdanlance
06/07/2023, 12:51 PMdanlance
06/07/2023, 12:51 PMzackster
06/07/2023, 12:53 PM