OyvindLGjesdal opened a new issue, #1396:
URL: https://github.com/apache/jena/issues/1396

   ### Version
   
   4.10
   
   ### What happened?
   
   A query with comments
   
   ```
   PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
   SELECT * WHERE { #ex1
     ?sub ?pred ?obj .  
     #ex2
   } LIMIT 10
   ```
   returns a log entry which requires manual intervention and/or guessing for 
being parseable again.
   
   The main issue seems to be that 
[SPARQLQueryProcessor.java](https://github.com/apache/jena/blob/main/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQLQueryProcessor.java#L238)
 calls 
[ServletOps.formatForLogs](https://github.com/apache/jena/blob/main/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ServletOps.java#L278)
 which replaces line characters with spaces (and return queries  the string 
`<null>` where queriy is `null`) before the configuration of the log format 
takes place. This means that we can't override the formatting of the query 
string log4j2.properties for to encode new lines, for simplyfying use in 
debugging.
   
   I think that removing the call to formatForLogs and moving the replacements 
to the configuration and fallback configuration of log4j2 makes sense.
   
   If the default log4j2.properties and the fallback configuration 
log4j2setupFallback then is changed to: 
   
   ```
   appender.console.layout.pattern = %d{HH:mm:ss} %-5p %-15c{1} :: 
%replace{%m}{[\n\r]}{ }%n
   ```
   I am then able to override the pattern in my own `log4j2.properties to 
return lines with `\\n\\r` in the log entry.
   ```
   appender.console.layout.pattern = %d{HH:mm:ss} %-5p %-15c{1} :: 
%enc{%m}{CRLF}{ }%n
   ```
   from (https://logging.apache.org/log4j/2.x/manual/layouts.html)
   
   I'm unsure what to do with the `<null>` return in this scenario.
   
   The purpose is mostly for the convenience of  debugging large/slow/wrong 
queries found in the logs. The queries are often templated, so it is convenient 
to reuse the fuseki log entry, then qparse it for formatting, and then copying 
it to e.g fuseki gui or yasgui for experimenting.
   
   ### Which environment is running?
   
   - [ ] macOS
   - [ ] Windows
   - [X] Linux
   - [ ] other
   
   ### Relevant output and stacktrace
   
   ```shell
   Jun 21 23:18:07 fuseki-test.novalocal fuseki-server[4067]: 23:18:07 INFO  
Fuseki          :: [4] Query = PREFIX rdf: 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: 
<http://www.w3.org/2000/01/rdf-schema#> SELECT * WHERE {   ?sub ?pred ?obj .    
 #test } LIMIT 10
   
   Jun 21 23:18:07 fuseki-test.novalocal fuseki-server[4067]: 23:18:07 WARN  
Fuseki          :: [4] Parse error: Encountered "<EOF>" at line 1, column 169.
   ```
   
   
   ### Are you interested in making a pull request?
   
   Yes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to