Closed jamiejackson closed 4 years ago
@jamiejackson This isn't an answer to your question but a possible work around in the meantime. Can you do this:
systemOutput( 'hi', true );
That function will also handle complex variables and writes to the standard out.
Also, when you asked about this in Slack the other day, I'm not sure if you mentioned that it was in regards to Docker. In Docker, the standard out is actually usually redirected to the output of the container itself. I'm not sure how the Lucee docker images handle this, but have you checked in the console logs for the container? It's entirely possible that it's not being written to a file at all.
On my Windows install of Lucee dump(var="hi", output="console")
writes to C:\lucee\tomcat\logs\lucee-stdout.YYYY-MM-DD.log
.
Checking on Ubuntu though it doesn't write to /opt/lucee/tomcat/logs/catalina.out
which is what I might have expected.
When I use dump(output: 'console')
, I see the output in the console where I started the container. So, I think this is working as expected and I recommend that this (very old) issue be closed.
I was pretty new to docker at the time, so I'm not quite sure what I was asking, but I'm not spotting a problem now:
$ docker run -it --rm -p:8888:8888 lucee/lucee:5.3 bash -c "echo '<cfscript>dump(var=\"hi\", output=\"console\");</cfscript>' > /var/www/index.cfm && catalina.sh run"
...
10-Feb-2020 23:06:04.806 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [5,443] milliseconds
...
# curl http://localhost:8888/
...
string hi
The same works for the image that I mentioned in the OP. Maybe I didn't know about the relationship between STDOUT and docker logs
then. 🤷♂
I was just in the middle of testing this myself and I think there's still an issue where the last console/system output on a page does not get rendered.
If I do this;
<cfdump output="console" var="hello 1">
<cfdump output="console" var="hello 2">
the console will print;
lucee_1 | string hello 1
If I make the same request again the console will print;
lucee_1 | string hello 2
lucee_1 | string hello 1
So the last thing that is outputted in the request ("hello 2") is never seen until the next request that also tries to output to the console / stdout. This seems to be very consistent. The exact same thing is happening for me with the systemOutput()
function (with or without the newline or error flag as 2nd and 3rd arguments).
In addition I've tried using Java System out directly, and this is where the results get wacky;
<cfset stdout = createObject("java", "java.lang.System").out>
<cfset stdout.println("===")>
<cfset stdout.println("hello A")>
<cfset stdout.println("hello B")>
<cfset stdout.println("---")>
The output will be in this case is usually 3 lines up to "hello B", but occassionally it's only 1, 2, or all 4 lines.
I'm using docker-compose on Windows for these tests, so I'm not sure yet if that's part of the issue or whether there's something else to be fixed. As far as Tomcat goes it's running in the foreground of the container so you should see std and stderr as normal for any foreground process.
Ok I can confirm my own hunch there, if I run with docker run -p:8888:8888 -v /workbench/lucee-dockerfiles/www:/var/www lucee/lucee:5.3
then all console output does get rendered every time;
string hello 1
string hello 2
===
hello A
hello B
---
So for me docker-compose
on windows is the culprit.
FROM lucee/lucee4:4.5.5.006
I'm not sure if this is a problem with the image or an upstream Lucee issue, but I can't find where
dump(var="hi", output="console")
writes.I've looked in:
/usr/local/tomcat/logs/*
/opt/lucee/web/logs/*.log
/opt/lucee/server/lucee-server/context/logs/*.log
The loss of that particular debugging tool is causing me problems.