• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

"File not found" error is not output to exception.log

Explorer ,
Aug 05, 2024 Aug 05, 2024

Copy link to clipboard

Copied

I use ColdFusion2021 update13, uses 2 logs that output to the api.log file (other logs output to other files)
 - one uses log4j2 (of update13) with CreateObject("java", "org.apache.logging.log4j.LogManager"),
 - the other uses my own build class CreateObject("java", "MyApiLog") (simply only logger.warn(str))
(both use 2 separate .properties files)
and uses the error-page <location>/Error404.cfm</location> handler in web.xml


After starting app server
At the Login screen (e.g. localhost:8500/index.cfm), when I access a non-existent file (e.g. localhost:8500/index.cfma)
the Error404.cfm runs OK and a "File not found" error (coldfusion.filter.ExceptionFilter$ApplicationExceptionWrapper: File not found: /Error404.cfm The specific sequence of files included or processed is: '''') is output to exception.log (up to here everything is OK)


After login ok (eg: localhost:8500/home/index.cfm), when I access a non-existent file (eg: localhost:8500/home/index.cfma)
the Error404.cfm runs OK but a "File not found" error is not output to exception.log but to the api.log
Why is the cause?

Views

624

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Aug 22, 2024 Aug 22, 2024

Charlie, BKBK

Now, my problem has been solved.
I just rewrote the 2 files below in log4j2 format.
-api4j.properties (logger.api.name = API)
-MyApiLog.java (logger = context.getLogger("API");)

I would like to close this conversation.
Thank you for your help!

Votes

Translate

Translate
Community Expert ,
Aug 05, 2024 Aug 05, 2024

Copy link to clipboard

Copied

Does the home folder have a different application.cfc or .cfm file? If so, that could explain the difference, if it has no similar 404 or other error handler. 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 06, 2024 Aug 06, 2024

Copy link to clipboard

Copied

There is only an Application.cfm file, and has no other error handler.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 06, 2024 Aug 06, 2024

Copy link to clipboard

Copied

Ok, but do you understand how the mere presence of that application file will cause a difference in processing between the two calls you list?


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 06, 2024 Aug 06, 2024

Copy link to clipboard

Copied

Sorry, I don't know. I would appreciate it if you could let me know.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 06, 2024 Aug 06, 2024

Copy link to clipboard

Copied

Let's clarify things first. You said above you have two urls with different paths which produce different results, localhost:8500/ and localhost:8500/home/. I'd asked if there was an application.cfm or application.cfc "in the home folder", and your reply was "There is only an Application.cfm file".

 

Can you confirm now if you mean there is a home/Application.cfm but no /Application.cfm? And in neither folder is there an Application.cfc, right? (If you're using Linux or MacOS the filename should start with a capital A, as you show. If it's Windows, the filenames are case-insensitive.)

 

And since you're showing use of localhost:8500 and tomcat config files (like web.xml), that suggests you're using the built-in web server of CF, so I assume your code is in your [coldfusion]/cfusion/wwwroot. As such, I'm asking if there's an application.cfm in that wwwroot and is there one also (or instead) in the cfusion/wwwroot/home folder under it.

 

If there is one in the home folder, it affects requests to that home folder--and that overrides any in the folder above it. This is how CF works. And since you're saying you experience different results in the two folders, I'm wondering if different Application files in them might be affecting your results.

 

Finally, you show controlling error handling via web.xml configuration. Is this destined to be a production server? Or would you use it as a development server used for staging code before deploying onto an intended prod server? If so, you'd not likely rely on that CF/Tomcat built-in web server in production. Have you considered using a web server like Apache or IIS (or even nginx)? Those would all offer their own means of handling 404's, which might save you some trouble.

 

Indeed, you show trying to handle requests for a .cfma file. If you used a different web server like those, such a request should never even make it to CF, as that's not a default file extension for CF files.


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 06, 2024 Aug 06, 2024

Copy link to clipboard

Copied

Thank you for your response!
I mean /Application.cfm
Right, in neither folder is there an Application.cfc
I haven't done anything to this folder [coldfusion]/cfusion/wwwroot
I have tested with file name indexx.cfm, same result (output error404 to api.log) on both linux and window.


Folder structure in linux:
/var/.../cfusion.war/
Application.cfm
index.cfm
Error404.cfm
home/index.cfm
WEB-INF/web.xml (using jboss(wildfly))
..(other files and folders)


in window:
C:\ColdFusion2021\mywebapp\wwwroot\
Application.cfm
index.cfm
Error404.cfm
home\index.cfm
WEB-INF\web.xml (using the built-in web server of CF)
..(other files and folders)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 07, 2024 Aug 07, 2024

Copy link to clipboard

Copied

I think Charlie has given you a good suggestion. You should place a second Application.cfm file in /home, that is, a new file, /home/Application.cfm. What happens then?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 07, 2024 Aug 07, 2024

Copy link to clipboard

Copied

Charlie, BKBK

Sorry my english is not good so caused misunderstanding.

I would like to add the following information.

The properties file used for my own java class "MyApiLog" is as follows:

# api4j.properties

log4j.rootLogger=WARN, R5

log4j.appender.R5.Threshold=WARN

log4j.appender.R5 = org.apache.log4j.DailyRollingFileAppender

log4j.appender.R5.File = C:\\ColdFusion2021\\mywebapp\\logs\\apilog\\api.log

log4j.appender.R5.Append = true

log4j.appender.R5.DatePattern = '.'yyyy-MM-dd

log4j.appender.R5.layout = org.apache.log4j.PatternLayout

log4j.appender.R5.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} - %m%n

 

When there is an error "File not found", CF2018 still outputs to exception.log (Coldfusion log), but CF2021 outputs to api.log.

So the configuration of exception.log (Coldfusion log) is overwritten?

Where is the configuration of exception.log configured?

 

Error details are as below:

2024-08-08 08:20:56 - File not found: /Error404.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\Error404.cfm''
coldfusion.filter.ExceptionFilter$ApplicationExceptionWrapper: File not found: /Error404.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\Error404.cfm''
at coldfusion.filter.ExceptionFilter.logErrorTofile(ExceptionFilter.java:471) ~[chf20210013.jar:development]
at coldfusion.filter.ExceptionFilter.handleException(ExceptionFilter.java:229) ~[chf20210013.jar:development]
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:114) ~[chf20210013.jar:development]
at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:81) ~[cfusion.jar:development]
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) ~[cfusion.jar:development]
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) ~[cfusion.jar:development]
at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:60) ~[cfusion.jar:development]
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) ~[cfusion.jar:development]
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) ~[cfusion.jar:development]
at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62) ~[cfusion.jar:development]
at coldfusion.CfmServlet.service(CfmServlet.java:231) ~[chf20210013.jar:development]
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:311) ~[cfmx_bootstrap.jar:development]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209) ~[catalina.jar:9.0.85]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[catalina.jar:9.0.85]
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:661) ~[catalina.jar:9.0.85]
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:427) ~[catalina.jar:9.0.85]
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:357) ~[catalina.jar:9.0.85]
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:294) ~[catalina.jar:9.0.85]
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:377) ~[catalina.jar:9.0.85]
at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:237) ~[catalina.jar:9.0.85]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:166) ~[catalina.jar:9.0.85]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) ~[catalina.jar:9.0.85]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[catalina.jar:9.0.85]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:355) ~[catalina.jar:9.0.85]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390) ~[tomcat-coyote.jar:9.0.85]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) ~[tomcat-coyote.jar:9.0.85]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:928) ~[tomcat-coyote.jar:9.0.85]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1794) ~[tomcat-coyote.jar:9.0.85]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) ~[tomcat-coyote.jar:9.0.85]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-util.jar:9.0.85]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-util.jar:9.0.85]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-util.jar:9.0.85]
at java.lang.Thread.run(Thread.java:834) ~[?:?]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 07, 2024 Aug 07, 2024

Copy link to clipboard

Copied

I would like to add the following information:

In the /Error404.cfm file (CF2021 on linux)

..

<cfinclude template="error_static404.cfm">

 

if add <cfabort> at the end like below:

..

<cfinclude template="error_static404.cfm">

<cfabort>

 

then "File not found" error will not output to api.log anymore (but still not output to exception.log)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 09, 2024 Aug 09, 2024

Copy link to clipboard

Copied

I would like to add the following information:

 

My webapp using a CustomTags: WEB-INF\..\CustomTags\Log.cfm
For debug i added: <cflog log="Application" type="ERROR" text="checkLog Type=#attributes.Type# Message=#attributes.Message#"> to Log.cfm,
and do the following in order:

step 1/access existent-file1.cfm (localhost:8500/index.cfm)
step 2/access non-existent-file1.cfm (localhost:8500/indexx.cfm)
step 3/access existent-file2.cfm (localhost:8500/home/index.cfm)
step 4/access non-existent-file2.cfm (localhost:8500/home/indexx.cfm)

 

Log output as below
exception.log
-- step 1 start --
"Error","http-nio-8500-exec-4","08/09/24","16:24:42","MyApp","checkLog Type=user Message=[Start] CALL login.cgi: 08/09/2024 16:24:42 236"
"Error","http-nio-8500-exec-4","08/09/24","16:24:42","MyApp","checkLog Type=User Message="
-- step 1 end --

-- step 2 start --
"Error","http-nio-8500-exec-8","08/09/24","16:25:23","","File not found: /indexx.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\indexx.cfm''"
coldfusion.runtime.TemplateNotFoundException: File not found: /indexx.cfm
at coldfusion.filter.PathFilter.invoke(PathFilter.java:165)
..(omit)
at java.base/java.lang.Thread.run(Thread.java:834)
-- step 2 end --

-- step 3 start --
"Error","http-nio-8500-exec-1","08/09/24","16:25:58","MyApp","checkLog Type=refer Message=URL:'http://localhost:8500/home/index.cfm' | SESSION-ID:'25414FE0AD8D..'"
"Error","http-nio-8500-exec-1","08/09/24","16:26:01","MyApp","checkLog Type=api Message=request Api.getApi1: [..]"

 

api.log (first line is log from my own java class "MyApiLog")
2024-08-09 16:26:01 - [SessionID] 25414FE0AD8D.. - [api] Api.getApi1 - [code] 200 - [time] 98ms
2024-08-09 16:26:02 - checkLog Type=api Message=response Api.getApi1: {..}
2024-08-09 16:26:02 - checkLog Type=user Message=api call: url=http://xxx, method=Api.getApi1, time=923ms.
2024-08-09 16:26:05 - checkLog Type=User Message=
-- step 3 end --

-- step 4 start --
2024-08-09 16:43:58 - File not found: /home/indexx.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\home\indexx.cfm''
coldfusion.filter.ExceptionFilter$ApplicationExceptionWrapper: File not found: /home/indexx.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\home\indexx.cfm''
at coldfusion.filter.ExceptionFilter.logErrorTofile(ExceptionFilter.java:477) [chf20210013.jar:development]
..(omit)
at java.lang.Thread.run(Thread.java:834) [?:?]
-- step 4 end --

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 11, 2024 Aug 11, 2024

Copy link to clipboard

Copied

This is getting complex. To me, at least. I find that there are too many changes happening at the same time. It is difficult to follow the discussion without first getting your answer to some of the basic questions asked.

  1.  Did you test by adding a separate Application.cfm file in the folder /home? If so, what was the result?
  2.  You appear to be running a Java application on the same Virtual Machine as ColdFusion, but separately from ColdFusion. If so, why? ColdFusion is itself a Java application. You could just integrate a Java application within ColdFusion. 
  3.  You asked, 'When there is an error "File not found", CF2018 still outputs to exception.log (Coldfusion log), but CF2021 outputs to api.log. So the configuration of exception.log (Coldfusion log) is overwritten?

    Where is the configuration of exception.log configured?' 
    No, I don't think exception.log is overwritten. Exception.log is automatically created and configured by ColdFusion itself, and should be located at C:\ColdFusion2021\mywebapp\logs\exception.log
    in your installation. Is the file present at that location?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 11, 2024 Aug 11, 2024

Copy link to clipboard

Copied

I have a different take than bkbk's reply today.  Rather then being concerned about you causing "too many changes happening at the same time", my concern is that you are juggling (and making us all juggle) too many variables.

 

1) For example, you're showing cf as on Windows and Linux--with the latter being cf on Jboss as a war. I appreciate that you were making the point that the problem happens on both. But since War deployment of cf is niche (limited in number)--and on jboss specifically is still more niche--let's stick with discussing what you experience with CF on Windows, unless and until you really have need to make a distinction between the two variants. That will simplify things here. 

 

1a) Second, your comments show running your Windows deployment of cf is as a cf instance called mywebapp. That was not indicated in your first post.

 

Indeed, I replied talking about how use of port 8500 implies your storing code in the cfusion/wwwroot, and you didn't correct me/us that you use /mywebapp/wwwroot. You simply showed using it in reply, and it's a subtle difference we had to discern. It might even be an important distinction: you'd definitely need to configure and look for things in different folders reflecting the correct instance. (And FWIW, your linux/jboss results then show you using cf's provided cfusion.war there, which I realize is the default war file name, but it could confuse matters for some trying to follow along.)

 

But perhaps more than important, when you show using port 8500, which was that on? Windows or Linux? Because when cf is installed as you have on Windows (NOT as a war), it defaults to using port 8500 for the cf admin and it uses the wwwroot (and logs) of the cfusion instance. Any new instance gets its own port, and a folder for the instance as a sibling to cfusion. 

 

1b) So could you just discuss things simply in the context of Windows and perhaps do things only in your cfusion instance? This will both simplify things for us and also increase the chance for you that more people reading along can relate (since the number of folks running cf as multiple instances is a minority). 

 

2) But most important, you're really throwing a curve ball with this whole matter of your java logging. And I get it: it's fundamental to what you want to do. But in the course of trying to understand how things are different for you since the move from CF2018 to cf2021, you've introduced not only the variety of differences I've relayed here, but it seems you're especially wanting to understand how 404 handling differs for you between cf2021 and 2018...and that on top of your own Java-based logging. Again, it's just too many variables.

 

2a) I'd strongly suggest you reduce your testing to one thing: in a stock deployment of cf2021 (on windows, in the cfusion/wwwroot, using port 8500),what happens for you when you run your 4 base scenarios?

 

Then introduce different variables, like adding a cflog, or adding your custom tag, or modifying any cf xml files. Then perhaps later try using a different instance.

 

Perhaps by starting from that "back to square one" approach, something may be more clear to you. Or it may be more clear to us.

 

3) Finally, I caught one key point you made, that the logging of things differed based on when you had or had not "logged in". That's certainly interesting, and you may want to elaborate on that.

 

Perhaps that's even possibly the most important point for you--but it's being lost in a flood of other concerns (and competing variables) being raised here.

 

Please make your testing as simple as possible. You may even find the answer on your own, suddenly. 🙂 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 12, 2024 Aug 12, 2024

Copy link to clipboard

Copied

BKBK, Charlie
Because my presentation is too complicated, I really apologize.
I will try to answer and simplify it step by step.

 

BKBK

1. Did you test by adding a separate Application.cfm file in the folder /home? If so, what was the result?

=> There is already an Application.cfm file in the mywebapp\wwwroot\ folder, and I have no intention of using the Application.cfm file anywhere else. So I didn't do this test.

 

2. You appear to be running a Java application on the same Virtual Machine as ColdFusion, but separately from ColdFusion. If so, why? ColdFusion is itself a Java application. You could just integrate a Java application within ColdFusion.
=> I just run Coldfusion, which has some java classes integrated under the folder: mywebapp\wwwroot\WEB-INF\..\classes\(my package xxx)\MyApiLog.class (and .java)

 

3. No, I don't think exception.log is overwritten. Exception.log is automatically created and configured by ColdFusion itself, and should be located at C:\ColdFusion2021\mywebapp\logs\exception.log in your installation. Is the file present at that location?
=> Yes, there is C:\ColdFusion2021\mywebapp\logs\exception.log (i mean exception.log)

 

 

Charlie
Thank you so much for showing me the details.

1)
=> The problem occurs on both, but let's just discuss CF on Windows.

 

1a)
=> Because of security I changed the post without noticing. I'm really sorry. (windows port is not 8500 but 85xx, like 8502)

 

1b)
=> Yes, for simplicity we only discuss CF on windows

 

2)
=> Your analysis is so accurate.
The problem arose when I went to upgrade from CF2018(log4j1) to CF2021(log4j2)

 

2a)
=> My 4 base scenarios was run at localhost:8502 on window (Once again, I'm really sorry about the port.)
exception.log
-- step 1 start --
"Error","http-nio-8502-exec-4","08/09/24","16:24:42","MyApp","checkLog Type=user Message=[Start] CALL login.cgi: 08/09/2024 16:24:42 236"
"Error","http-nio-8502-exec-4","08/09/24","16:24:42","MyApp","checkLog Type=User Message="
-- step 1 end --

-- step 2 start --
"Error","http-nio-8502-exec-8","08/09/24","16:25:23","","File not found: /indexx.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\indexx.cfm''"
coldfusion.runtime.TemplateNotFoundException: File not found: /indexx.cfm
at coldfusion.filter.PathFilter.invoke(PathFilter.java:165)
..(omit)
at java.base/java.lang.Thread.run(Thread.java:834)
-- step 2 end --

-- step 3 start --
"Error","http-nio-8502-exec-1","08/09/24","16:25:58","MyApp","checkLog Type=refer Message=URL:'http://localhost:8502/home/index.cfm' | SESSION-ID:'25414FE0AD8D..'"
"Error","http-nio-8502-exec-1","08/09/24","16:26:01","MyApp","checkLog Type=api Message=request Api.getApi1: [..]"

 

api.log (first line is log from my own java class "MyApiLog")
2024-08-09 16:26:01 - [SessionID] 25414FE0AD8D.. - [api] Api.getApi1 - [code] 200 - [time] 98ms
2024-08-09 16:26:02 - checkLog Type=api Message=response Api.getApi1: {..}
2024-08-09 16:26:02 - checkLog Type=user Message=api call: url=http://xxx, method=Api.getApi1, time=923ms.
2024-08-09 16:26:05 - checkLog Type=User Message=
-- step 3 end --

-- step 4 start --
2024-08-09 16:43:58 - File not found: /home/indexx.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\home\indexx.cfm''
coldfusion.filter.ExceptionFilter$ApplicationExceptionWrapper: File not found: /home/indexx.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\home\indexx.cfm''
at coldfusion.filter.ExceptionFilter.logErrorTofile(ExceptionFilter.java:477) [chf20210013.jar:development]
..(omit)
at java.lang.Thread.run(Thread.java:834) [?:?]
-- step 4 end --


In the output log above, there are 2 points to note that I don't understand as below:

a/ In step 3:
When the Api.getApi1 method (in my own java class) is called (last line of exception.log file)
the log handle starts transferring output to the api.log file (first line, up to here it's still OK)
but it does not return to the output in the exception.log file but continues to output in the api.log file

(from the 2nd line onwards in api.log, if it go back and output in exception.log it will be ok, api.log file should have only one red line)

b/ The "File not found" in step 2 is slightly different from step 4 in that it has the word "Error" at the beginning of the line.

(maybe due to layout pattern)

 

3)
=> Yes, There is once difference before (had not logged) and after (had logged) calling Api.getApi1 (in my own java class)
When the api has not been called, the log handle seems to output correctly exception.log
But after calling the api, the log handle does not return to output log at exception.log anymore.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 15, 2024 Aug 15, 2024

Copy link to clipboard

Copied

I would like to add more information: cf2021_update10 OK but cf2021_update11 NG.

I'm checking again for my update 11..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 16, 2024 Aug 16, 2024

Copy link to clipboard

Copied

To avoid confusion, if only mine, let's review the discussion, starting from the top.

After starting app server
At the Login screen (e.g. localhost:8500/index.cfm), when I access a non-existent file (e.g. localhost:8500/index.cfma)
the Error404.cfm runs OK and a "File not found" error (coldfusion.filter.ExceptionFilter$ApplicationExceptionWrapper: File not found: /Error404.cfm The specific sequence of files included or processed is: '''') is output to exception.log (up to here everything is OK)

I am surprised that you say, "the Error404.cfm runs OK". The application actually gave the message, "File not found: /Error404.cfm".

After login ok (eg: localhost:8500/home/index.cfm), when I access a non-existent file (eg: localhost:8500/home/index.cfma)
the Error404.cfm runs OK but a "File not found" error is not output to exception.log but to the api.log
Why is the cause?

Charlie already answered that. The error is not related to ColdFusion. As CFMA is not one of ColdFusion's file types, the web server won't send the request to ColdFusion. So you should not expect to see any error message in ColdFusion's logs. The error message would probably be determined by the web server.

=> I just run Coldfusion, which has some java classes integrated under the folder: mywebapp\wwwroot\WEB-INF\..\classes\(my package xxx)\MyApiLog.class (and .java)
=> Yes, there is C:\ColdFusion2021\mywebapp\logs\exception.log (i mean exception.log)
=> The problem occurs on both, but let's just discuss CF on Windows.
=> Because of security I changed the post without noticing. I'm really sorry. (windows port is not 8500 but 85xx, like 8502)
=> Yes, for simplicity we only discuss CF on windows

 All good.

The problem arose when I went to upgrade from CF2018(log4j1) to CF2021(log4j2)

ColdFusion 2018 comes with all the necessary packages installed. There was a major change from ColdFusion 2018 to ColdFusion 2021. The latter has a modular architecture. This is implemented by means of a Package Manager, which enables the addition or removal of packages.

So, a suggestion here is to add all the available packages in CF2021 before comparing the functionality of CF2018 and CF2021.  

step 1/access existent-file1.cfm (localhost:8500/index.cfm)
...
...
exception.log
-- step 1 start --
"Error","http-nio-8500-exec-4","08/09/24","16:24:42","MyApp","checkLog Type=user Message=[Start] CALL login.cgi: 08/09/2024 16:24:42 236"
"Error","http-nio-8500-exec-4","08/09/24","16:24:42","MyApp","checkLog Type=User Message="
-- step 1 end --

Why the request to a CGI template in a CFML application? I would expect the web server to respond as it did with the request to the CFMA template. In other words, it is unlikely that these error messages were logged by ColdFusion. 
Did you perhaps intend to use login.cfm instead of login.cgi?

step 2/access non-existent-file1.cfm (localhost:8500/indexx.cfm)
...
...
exception.log
...
-- step 2 start --
"Error","http-nio-8500-exec-8","08/09/24","16:25:23","","File not found: /indexx.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\indexx.cfm''"
coldfusion.runtime.TemplateNotFoundException: File not found: /indexx.cfm
at coldfusion.filter.PathFilter.invoke(PathFilter.java:165)
..(omit)
at java.base/java.lang.Thread.run(Thread.java:834)
-- step 2 end --

That is as expected.

step 3/access existent-file2.cfm (localhost:8500/home/index.cfm)
...
...
exception.log
...
...
-- step 3 start --
"Error","http-nio-8500-exec-1","08/09/24","16:25:58","MyApp","checkLog Type=refer Message=URL:'http://localhost:8500/home/index.cfm' | SESSION-ID:'25414FE0AD8D..'"
"Error","http-nio-8500-exec-1","08/09/24","16:26:01","MyApp","checkLog Type=api Message=request Api.getApi1: [..]"

api.log (first line is log from my own java class "MyApiLog")
2024-08-09 16:26:01 - [SessionID] 25414FE0AD8D.. - [api] Api.getApi1 - [code] 200 - [time] 98ms
2024-08-09 16:26:02 - checkLog Type=api Message=response Api.getApi1: {..}
2024-08-09 16:26:02 - checkLog Type=user Message=api call: url=http://xxx, method=Api.getApi1, time=923ms.
2024-08-09 16:26:05 - checkLog Type=User Message=
-- step 3 end --

OK, the API writes to api.log. But these logs suggest to me that there are two separate processes writing to exception.log, namely ColdFusion and the API. Possibly simultaneously. 

If so, then there might occasionally be contention between the two, as to whose writing thread currently holds the lock on the log file.

Suggestion: configure the API to write to the API log only.

step 4/access non-existent-file2.cfm (localhost:8500/home/indexx.cfm)
...
...
exception.log
...
-- step 4 start --
2024-08-09 16:43:58 - File not found: /home/indexx.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\home\indexx.cfm''
coldfusion.filter.ExceptionFilter$ApplicationExceptionWrapper: File not found: /home/indexx.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\home\indexx.cfm''
at coldfusion.filter.ExceptionFilter.logErrorTofile(ExceptionFilter.java:477) [chf20210013.jar:development]
..(omit)
at java.lang.Thread.run(Thread.java:834) [?:?]
-- step 4 end --

That is as expected.

I would like to add more information: cf2021_update10 OK but cf2021_update11 NG.

I'm checking again for my update 11.

Why Update 11? You should just apply the most up-to-date update, namely, ColdFusion 2021 Update 13. Remember to add all available packages afterwards.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 19, 2024 Aug 19, 2024

Copy link to clipboard

Copied

BKBK
Thank you for your response!


I say "the Error404.cfm runs OK", i mean "Missing Template Handler" has no problem.
Regarding the cfma file type i used, it was incorrect. I corrected it to use a .cfm file with any file name that doesn't exist.(as step2.cfm, step4.cfm below)
About CF2018 -> CF2021 we don't need to care anymore, we are only mention to CF2021 update10 -> update11.
About CGI too, we don't need to care anymore, we are only mention to the content we want to be logged.
The content in exception.log is logged from CF.
The content in api.log is logged from myapp (not CF).
I guess the problem might be with the log4j2 (2.17.2(CF21 update10) -> 2.20.0(CF21 update11))


In short, let's start over as below.

Premise:
\Error404.cfm (in Missing Template Handler)
..
<cf_log type="user" message="Error404 run OK" >
<cfinclude template="/errorStatic404.cfm">

 

\WEB-INF\...\CustomTags\Log.cfm (for debug checklog)
..
<cflog log="Application" type="ERROR" text="checkLog Type=#attributes.Type# Message=#attributes.Message#">

 

\step1.cfm
<cfdump var="call api by cfhttp - start">
<cfhttp method="get" url="http://xxx../apiX" result="response" resolveurl="Yes" timeout="30">
</cfhttp>
<cf_log type="api" message="log api by cfhttp">
<cfdump var="call api by cfhttp - end">

 

\step3.cfm
<cfdump var="call api by MyApiLog - start">
<cfset a_client=CreateObject("java", "(my package)xxx..MyApiLog")>
<cfset a_client.init()>
<cfset a_serverResult=a_client.getApi1()>
<cfdump var="call api by MyApiLog - end">

 

\WEB-INF\...\classes\(my package xxx)\api4j.properties
log4j.rootLogger=WARN, R5
log4j.appender.R5.Threshold=WARN
log4j.appender.R5 = org.apache.log4j.DailyRollingFileAppender
log4j.appender.R5.File = C:\\ColdFusion2021\\mywebapp\\logs\\apilog\\api.log
log4j.appender.R5.Append = true
log4j.appender.R5.DatePattern = '.'yyyy-MM-dd
log4j.appender.R5.layout = org.apache.log4j.PatternLayout
log4j.appender.R5.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} - %m%n

 

\WEB-INF\...\classes\(my package xxx)\MyApiLog.java

 

 

 

package xxx..api;
import java.io.IOException;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class MyApiLog {
	public static Logger logger = Logger.getLogger(MyApiLog.class.getName());
	private final String prop_file = "api4j.properties";
	
	public MyApiLog(){
		Properties props = new Properties();
		try {
			props.load(getClass().getResourceAsStream(prop_file));
		} catch (IOException e) {
			e.printStackTrace();
		}
		PropertyConfigurator.configure(props);
	}
	public void WriteLogger(String str){
	    logger.warn(str);
	}

	public Object getApi1() throws IOException {
		String str = "[SessionID] 25414FE0AD8D.. - [api] Api.getApi1 - [code] 200 - [time] 98ms";
		this.WriteLogger(str);
		return null;
	}
}

 

 

 

 

After run 4 scenarios below:
step 1/access existent-file.cfm (localhost:8502/step1.cfm)
step 2/access non-existent-file.cfm (localhost:8502/step2.cfm)
step 3/access existent-file.cfm (localhost:8502/step3.cfm)
step 4/access non-existent-file.cfm (localhost:8500/step4.cfm)

 

Result (NG) on CF21 update11.
(in api.log file there should be only 2 lines similar to update10 below)

 

application.log
-- step 1 start --
"Error","http-nio-8502-exec-2","08/19/24","11:40:11","MyApp","checkLog Type=apij Message=log api by cfhttp"
"Error","http-nio-8502-exec-2","08/19/24","11:40:12","MyApp","checkLog Type=User Message="
-- step 1 end --
-- step 2 start --
"Error","http-nio-8502-exec-3","08/19/24","11:41:18","MyApp","checkLog Type=user Message=Error404 run OK"
"Error","http-nio-8502-exec-3","08/19/24","11:41:18","MyApp","File not found: /step2.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\step2.cfm''"
-- step 2 end --
-- step 3 start --
-- step 3 end --
-- step 4 start --
-- step 4 end --

 

exception.log
-- step 1 start --
"Error","http-nio-8502-exec-2","08/19/24","11:40:11","MyApp","checkLog Type=apij Message=log api by cfhttp"
"Error","http-nio-8502-exec-2","08/19/24","11:40:12","MyApp","checkLog Type=User Message="
-- step 1 end --
-- step 2 start --
"Error","http-nio-8502-exec-3","08/19/24","11:41:18","MyApp","checkLog Type=user Message=Error404 run OK"
"Error","http-nio-8502-exec-3","08/19/24","11:41:18","MyApp","File not found: /step2.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\step2.cfm''"
coldfusion.runtime.TemplateNotFoundException: File not found: /step2.cfm
..(omit)
at java.base/java.lang.Thread.run(Thread.java:834)
-- step 2 end --
-- step 3 start --
-- step 3 end --
-- step 4 start --
-- step 4 end --

 

api.log (Orange lines should not be in here)
-- step 1 start --
2024-08-19 11:40:11 - log api by cfhttp
-- step 1 end --
-- step 2 start --
-- step 2 end --
-- step 3 start --
2024-08-19 11:42:29 - [SessionID] 25414FE0AD8D.. - [api] Api.getApi1 - [code] 200 - [time] 98ms
2024-08-19 11:42:29 - checkLog Type=User Message=
-- step 3 end --
-- step 4 start --
2024-08-19 11:43:38 - checkLog Type=user Message=Error404 run OK
2024-08-19 11:43:38 - File not found: /step4.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\step4.cfm''
coldfusion.filter.ExceptionFilter$ApplicationExceptionWrapper: File not found: /step4.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\step4.cfm''
..(omit)
at java.lang.Thread.run(Thread.java:834) [?:?]
-- step 4 end --


Result (OK) on CF21 update10 (downgraded).

 

application.log
-- step 1 start --
"Error","http-nio-8502-exec-5","08/19/24","11:55:20","MyApp","checkLog Type=apij Message=log api by cfhttp"
"Error","http-nio-8502-exec-5","08/19/24","11:55:21","MyApp","checkLog Type=User Message="
-- step 1 end --
-- step 2 start --
"Error","http-nio-8502-exec-8","08/19/24","11:56:11","MyApp","checkLog Type=user Message=Error404 run OK"
"Error","http-nio-8502-exec-8","08/19/24","11:56:11","MyApp","File not found: /step2.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\step2.cfm'' "
-- step 2 end --
-- step 3 start --
"Error","http-nio-8502-exec-9","08/19/24","11:56:57","MyApp","checkLog Type=User Message="
-- step 3 end --
-- step 4 start --
"Error","http-nio-8502-exec-3","08/19/24","11:57:48","MyApp","checkLog Type=user Message=Error404 run OK"
"Error","http-nio-8502-exec-3","08/19/24","11:57:48","MyApp","File not found: /step4.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\step4.cfm'' "
-- step 4 end --

 

exception.log
-- step 1 start --
-- step 1 end --
-- step 2 start --
"Error","http-nio-8502-exec-8","08/19/24","11:56:11","MyApp","File not found: /step2.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\step2.cfm'' "
coldfusion.runtime.TemplateNotFoundException: File not found: /step2.cfm
..(omit)
at java.base/java.lang.Thread.run(Thread.java:834)
-- step 2 end --
-- step 3 start --
-- step 3 end --
-- step 4 start --
"Error","http-nio-8502-exec-3","08/19/24","11:57:48","MyApp","File not found: /step4.cfm The specific sequence of files included or processed is: C:\ColdFusion2021\mywebapp\wwwroot\step4.cfm'' "
coldfusion.runtime.TemplateNotFoundException: File not found: /step4.cfm
..(omit)
at java.base/java.lang.Thread.run(Thread.java:834)
-- step 4 end --

 

api.log
-- step 1 start --
2024-08-19 11:55:21 - log api by cfhttp
-- step 1 end --
-- step 2 start --
-- step 2 end --
-- step 3 start --
2024-08-19 11:56:57 - [SessionID] 25414FE0AD8D.. - [api] Api.getApi1 - [code] 200 - [time] 98ms
-- step 3 end --
-- step 4 start --
-- step 4 end --

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 22, 2024 Aug 22, 2024

Copy link to clipboard

Copied

Charlie, BKBK

Now, my problem has been solved.
I just rewrote the 2 files below in log4j2 format.
-api4j.properties (logger.api.name = API)
-MyApiLog.java (logger = context.getLogger("API");)

I would like to close this conversation.
Thank you for your help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 23, 2024 Aug 23, 2024

Copy link to clipboard

Copied

LATEST

Hi @VietTruong , I am glad to read that your problem has been solved. Thanks for sharing the solution.

Good luck and have fun with the rest of the project.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation