Asking this here since some of the Ortus folks are...
# lucee
q
Asking this here since some of the Ortus folks are here... What is the magic to get the Lucee Hibernate ORM or the Ortus ORM extension to create logs? I'm not using CommandBox (using the official lucee docker and standalone), and from what I remember, there is some config in the Log4J that needs to be mucked with to get the logs to be created....
This is when using the ORM settings "logSQL=true" property
b
@mborn
l
@mborn help
m
Hey @quetwo, what sort of logs are you looking for? The Ortus ORM Extension fixes Hibernate logging for ERROR-level log items, but we don't currently support a finer log level than that. > What is the magic to get the Lucee Hibernate ORM or the Ortus ORM extension to create logs? These are two different beasts and it depends on which you're asking about, as well as which Lucee version you are on. 1. For the Ortus ORM Extension (OOE), ERROR logs automatically output to the server console. I haven't tested this outside of CommandBox setup, so let me know if you're using the Ortus extension and not seeing console logs for Hibernate's
ERROR
log level. 2. For the Lucee Hibernate extension, it depends on your version of Lucee - specifically, on whether you're on Log4J 2 or not. a. For log4j 1.x, you can use this code to redirect the Hibernate logs to the server console: https://github.com/coldbox-modules/cborm/blob/0454a20a64dfd0218e8cfa810b2582ec877eebaf/models/util/ORMUtilSupport.cfc#L17-L42 b. For log4j 2.x, good luck my friend. 🙂 I was never able to figure out how to capture and redirect Hibernate's logs to the server console. If do you figure it out, please do let us know the config and we can add it in our docs. If not, I would suggest sponsoring a log4j expert such as @bdw429s to get this working for you.
q
I'm not sure if the error logs are getting transported to the orm.log files or the console as expected, but if you set the
logSQL
directive in the ormSettings (on the application scope), it is not logging. I can try and see if I can generate logs for this, but I don't don't think I've ever seen any -- even on db connect issues. Logging the attempted queries is a great debugging tool, esp if you are doing your own HQL and trying to figure out why Lucee/Hibernate is giving unexpected results -- and it is listed as a valid configuration item : https://orm-extension.ortusbooks.com/getting-started/configuration
But ultimately, I'd love to get this to work with the OOE, since it sounds like Lucee is looking to no longer support their extension going forward.
m
Which extension are you using? If you're using the Lucee Hibernate extension, then yes, logging is likely broken. I had to fix this in our forked extension, but I don't know if the Lucee devs fixed it in their original repo before they stopped maintenance.
And which extension version? IIRC, logging was working prior to the Hibernate v5.x upgrade. So the Lucee extension version 3.5.5 should still work... but that may not be true on Log4j2 either. There's a lot of details in play here, so what you're using is pretty important.
Are you on a docker image? This may be specific to the lucee docker image as well... though I'd guess the issue occurs regardless of your deployment type. https://luceeserver.atlassian.net/browse/LDEV-4586
q
I'm specifically using OOE 5.4.29.26. I've moved most of my app over to use that. I feel like the logSQL was working at some time, but it hasn't for a while.
I am trying on the docker image. but also not seeing the logging on the standalone deployment either. Docker is my primary deployments.
m
You need to be on v6.0.0 at least. Looks like that's the version where we fixed logging, including
this.ormSettings.logSQL
. https://github.com/Ortus-Solutions/extension-hibernate/releases/tag/v6.0.0
@quetwo hope that helps.
You should see a big improvement in application startup time, as well as a number of bug fixes, if you switch to the latest version or at least 6.0.0. But for logging specifically, you need to be on 6.0.0 or greater.
q
So, I did quite a bit more testing, and with OOM 6.5.2, running on CommandBox, using the built-in Lucee server (with no params) on Linux, the orm.log files (both in the context and on the server directive) are not getting updated. Application.cfc :
Copy code
component
{

        this.name="test";
        this.datasource="ormtest";
        this.ormEnabled=true;
        this.ormSettings=
        {
                logSQL:true,
                cfclocation="db",
                dbcreate="update"
        };

}
db/configItem.cfc:
Copy code
component persistent="true" table="appConfig" cacheUse="nonstrict-read-write"
{
    // This ORM component is ued to store application variables in the database.

    property name="id" fieldtype="id" generator="native" column="configID";
    property name="name" fieldtype="column" ormType="string" column="configItem";
    property name="value" fieldtype="column" ormType="string" column="configValue";

}
test.cfm:
Copy code
<cfscript>
ormReload();
test = EntityLoad("configItem");
</cfscript>

<cfdump var="#test#">
box.json:
Copy code
{
  "dependencies": {
    "D062D72F-F8A2-46F0-8CBC91325B2F067B": "^6.5.2"
  }
}
@mborn -- any idea on where to start looking or testing?
Setting the logging level for the ORM log directive to "TRACE" or "DEBUG" also results in nothing written to disk when I do anything ORM related.
m
Ok, I didn't know you were only interested in the ORM.log file. I'm pretty sure that's not working since the update to hibernate 5.4 (or possibly since lucee updated to log4j2.)
Are you seeing orm logging in the console?
I can likely add a bit of handling to output logging to A log file, but as I recall it was wildly difficult / complex to pass logging back through lucee's logs to obey logging settings and save to the orm.log file. And since I'm buried in client work and other projects, I don't know when I can get to this. Sponsoring this logging fix would go a long way towards getting it out there sooner. 🙂
q
Since I'm using this primary through Docker, linking the orm.log files to the /dev/stdout is where I would expect them. BUT if the expectation is they are going to the console, I don't see them there either (in Docker or via commandbox's
server log
function). As it is working now, how would I expect to see that output?
m
Ok, you should definitely be seeing them in the console, aka via
server log
.
I have no idea why they're not showing in the console for you, as they definitely do for me.
But I did replicate that no ORM logs are going into the
orm.log
file. I can hopefully have a fix for this within the month, @quetwo. Right now client work / sponsored development is getting the priority. Sorry about the wait.
I wrote up the orm.log issue. Feel free to check back here for progress updates. https://ortussolutions.atlassian.net/browse/OOE-27
q
Thanks! Appreciate the help.