Current version of logback can't read my JNDI entry

I'm running a program on a WebSphere Liberty 21.0.0.11 with logging from logback 1.2.11. I have a log output folder specified in my server.xml as: <jndiEntry jndiName="logging/logPath" value="${server.output.dir}/logs"/> In the logback.xml I read this entry with the line: <insertFromJNDI env-entry-name="logging/logPath" as="logPath"/> This worked in the old logback versions However in the new version of logback this name is not allowed as the name now must start with "java:". So when I tried to change the line to: <insertFromJNDI env-entry-name="java:comp/env/logging/logPath" as="logPath"/> I get 14:37:59,720 |-ERROR in ch.qos.logback.classic.joran.action.InsertFromJNDIAction - Failed to lookup JNDI env-entry [java:comp/env/stibam/logPath] javax.naming.NamingException: CWNEN1000E: Is there an error in my reading out of that JNDI variable?

Hello Hendrik, The new JNDI naming restriction is intended to prevent malicious JNDI attacks in configuration files. Do you know which Jakarta/EE/JavaEE specification WebSphere Liberty 21 implements? I would suggest reading section "Application Component Environment Namespace" in the relevant document. You might try to use one of the following namespaces: java:comp, java:module, java:app, java:global with and without the env/ suffix. -- Ceki Gülcü Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch On 3/30/2022 3:01 PM, Hendrik Stichweh wrote:
I'm running a program on a WebSphere Liberty 21.0.0.11 with logging from logback 1.2.11.
I have a log output folder specified in my server.xml as: <jndiEntry jndiName="logging/logPath" value="${server.output.dir}/logs"/>
In the logback.xml I read this entry with the line: <insertFromJNDI env-entry-name="logging/logPath" as="logPath"/>
This worked in the old logback versions However in the new version of logback this name is not allowed as the name now must start with "java:".
So when I tried to change the line to: <insertFromJNDI env-entry-name="java:comp/env/logging/logPath" as="logPath"/>
I get
|14:37:59,720 |-ERROR in ch.qos.logback.classic.joran.action.InsertFromJNDIAction - Failed to lookup JNDI env-entry [java:comp/env/stibam/logPath] javax.naming.NamingException: CWNEN1000E: |
Is there an error in my reading out of that JNDI variable?

Hello Ceki, thank you for your answer! I tried your examples but no luck. Actually now I think the error that is given to me mentions that any entry starting with "java:*" will be not read. The message is in german but I translated it: ERROR in ch.qos.logback.classic.joran.action.InsertFromJNDIAction - Failed to lookup JNDI env-entry [java:global/stibam] javax.naming.NamingException: CWNEN1000E: A JNDI operation for a java:comp/env- Names cannot be executed because the current thread is not associated with a Java EE (Java Enterprise Edition) application component. This condition can occur when the JNDI client using the java:comp/env name is not in the thread of a server application request. Ensure that a Java EE application does not perform JNDI operations on java:comp/env names in static code blocks or in threads created by that application. Such code is not necessarily executed in a server application request thread and is therefore not supported by JNDI operations on java:comp/env names. As a workaround, to not having to use JNDI, I just used the actual filepath in the logback.xml as: <File>"${server.output.dir}logs/log-output.log</File> Which solves the first problem but now logback doesn't seem to be able to acces the file (if i copy and paste the filepath from the log output following I can open that file with explorer):. If I start my program I get the following log output. 23:16:12,543 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[RollApp] - Active log file name: "F:/server/wlp-ev-21.0.0.11/usr/servers/defaultServer/logs/log-output.log 23:16:12,543 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[RollApp] - File property is set to ["F:/server/wlp-ev-21.0.0.11/usr/servers/defaultServer/logs/log-output.log] 23:16:12,546 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[RollApp] - Failed to create parent directories for [F:\server\wlp-ev-21.0.0.11\usr\servers\defaultServer\"F:\server\wlp-ev-21.0.0.11\usr\servers\defaultServer\logs\log-output.log] 23:16:12,547 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[RollApp] - openFile("F:/server/wlp-ev-21.0.0.11/usr/servers/defaultServer/logs/log-output.log,true) call failed. java.io.FileNotFoundException: "F:\server\wlp-ev-21.0.0.11\usr\servers\defaultServer\logs\log-output.log (Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch) at java.io.FileNotFoundException: "F:\server\wlp-ev-21.0.0.11\usr\servers\defaultServer\logs\log-output.log (Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch) at at java.io.FileOutputStream.open0(Native Method) I guess this has more to do with my project setup now. On Wed, Mar 30, 2022 at 8:22 PM Ceki Gülcü <ceki@qos.ch> wrote:
Hello Hendrik,
The new JNDI naming restriction is intended to prevent malicious JNDI attacks in configuration files.
Do you know which Jakarta/EE/JavaEE specification WebSphere Liberty 21 implements? I would suggest reading section "Application Component Environment Namespace" in the relevant document.
You might try to use one of the following namespaces:
java:comp, java:module, java:app, java:global
with and without the env/ suffix.
-- Ceki Gülcü
Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch
On 3/30/2022 3:01 PM, Hendrik Stichweh wrote:
I'm running a program on a WebSphere Liberty 21.0.0.11 with logging from logback 1.2.11.
I have a log output folder specified in my server.xml as: <jndiEntry jndiName="logging/logPath" value="${server.output.dir}/logs"/>
In the logback.xml I read this entry with the line: <insertFromJNDI env-entry-name="logging/logPath" as="logPath"/>
This worked in the old logback versions However in the new version of logback this name is not allowed as the name now must start with "java:".
So when I tried to change the line to: <insertFromJNDI env-entry-name="java:comp/env/logging/logPath" as="logPath"/>
I get
|14:37:59,720 |-ERROR in ch.qos.logback.classic.joran.action.InsertFromJNDIAction - Failed to lookup JNDI env-entry [java:comp/env/stibam/logPath] javax.naming.NamingException: CWNEN1000E: |
Is there an error in my reading out of that JNDI variable?
_______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

I realized what the problem was: <File>"${server.output.dir}logs/log-output.log</File> returns the drive (F:\server\...) with an uppercase letter for the drive and thus logback can't find the file in the filesystem. I'm not sure how to return in in lowercase but at least I have the culprit now. On Thu, Mar 31, 2022 at 12:01 AM Hendrik Stichweh <hendrikstichweh@gmail.com> wrote:
Hello Ceki,
thank you for your answer! I tried your examples but no luck. Actually now I think the error that is given to me mentions that any entry starting with "java:*" will be not read. The message is in german but I translated it:
ERROR in ch.qos.logback.classic.joran.action.InsertFromJNDIAction - Failed to lookup JNDI env-entry [java:global/stibam] javax.naming.NamingException: CWNEN1000E: A JNDI operation for a java:comp/env- Names cannot be executed because the current thread is not associated with a Java EE (Java Enterprise Edition) application component. This condition can occur when the JNDI client using the java:comp/env name is not in the thread of a server application request. Ensure that a Java EE application does not perform JNDI operations on java:comp/env names in static code blocks or in threads created by that application. Such code is not necessarily executed in a server application request thread and is therefore not supported by JNDI operations on java:comp/env names.
As a workaround, to not having to use JNDI, I just used the actual filepath in the logback.xml as: <File>"${server.output.dir}logs/log-output.log</File>
Which solves the first problem but now logback doesn't seem to be able to acces the file (if i copy and paste the filepath from the log output following I can open that file with explorer):. If I start my program I get the following log output.
23:16:12,543 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[RollApp] - Active log file name: "F:/server/wlp-ev-21.0.0.11/usr/servers/defaultServer/logs/log-output.log 23:16:12,543 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[RollApp] - File property is set to ["F:/server/wlp-ev-21.0.0.11/usr/servers/defaultServer/logs/log-output.log] 23:16:12,546 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[RollApp] - Failed to create parent directories for [F:\server\wlp-ev-21.0.0.11\usr\servers\defaultServer\"F:\server\wlp-ev-21.0.0.11\usr\servers\defaultServer\logs\log-output.log] 23:16:12,547 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[RollApp] - openFile("F:/server/wlp-ev-21.0.0.11/usr/servers/defaultServer/logs/log-output.log,true) call failed. java.io.FileNotFoundException: "F:\server\wlp-ev-21.0.0.11\usr\servers\defaultServer\logs\log-output.log (Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch) at java.io.FileNotFoundException: "F:\server\wlp-ev-21.0.0.11\usr\servers\defaultServer\logs\log-output.log (Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch) at at java.io.FileOutputStream.open0(Native Method)
I guess this has more to do with my project setup now.
On Wed, Mar 30, 2022 at 8:22 PM Ceki Gülcü <ceki@qos.ch> wrote:
Hello Hendrik,
The new JNDI naming restriction is intended to prevent malicious JNDI attacks in configuration files.
Do you know which Jakarta/EE/JavaEE specification WebSphere Liberty 21 implements? I would suggest reading section "Application Component Environment Namespace" in the relevant document.
You might try to use one of the following namespaces:
java:comp, java:module, java:app, java:global
with and without the env/ suffix.
-- Ceki Gülcü
Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch
On 3/30/2022 3:01 PM, Hendrik Stichweh wrote:
I'm running a program on a WebSphere Liberty 21.0.0.11 with logging from logback 1.2.11.
I have a log output folder specified in my server.xml as: <jndiEntry jndiName="logging/logPath" value="${server.output.dir}/logs"/>
In the logback.xml I read this entry with the line: <insertFromJNDI env-entry-name="logging/logPath" as="logPath"/>
This worked in the old logback versions However in the new version of logback this name is not allowed as the name now must start with "java:".
So when I tried to change the line to: <insertFromJNDI env-entry-name="java:comp/env/logging/logPath" as="logPath"/>
I get
|14:37:59,720 |-ERROR in ch.qos.logback.classic.joran.action.InsertFromJNDIAction - Failed to lookup JNDI env-entry [java:comp/env/stibam/logPath] javax.naming.NamingException: CWNEN1000E: |
Is there an error in my reading out of that JNDI variable?
_______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
participants (2)
-
Ceki Gülcü
-
Hendrik Stichweh