Skip to Content

Logging properties customization for SAP HCP Java Application

Hi, Could anyone please suggest how to configure properly logging.properties file for SAP HCP Java application. What I want to achieve is adding new sections which I would like to log, but no any documentation among SAP HCP Wiki. I believe to do everything correctly I need to know initial logging properties which are used to output console records

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 27 at 09:22 PM

    Hi Nikolay,

    Good news and bad news.

    The good news is that it is possible to log other data into the log files and have access to them via cockpit. The bad news is that you cannot use any of the standard methods known in Spring and it is not as easy as it sounds.

    I've discussed this topic with several internal colegues and here are my findings:

    (1) Neo completely replaces any log facility you have on Spring - including logback, log4j, slf4j, etc.

    (2) For additional logging formats, you must implement your own log facility that writes log entries at the following location: "/usr/sap/ljs/log" and the filename must be "application.log"

    (3) Variables must have the separator "#" - so you cannot write anything with commas, spaces or dashes.

    (4) Your log file will have last execution priority in the tread model. Therefore, your entries will be placed in the cockpit long after the application interaction.

    (5) Your log entries will appear in the cockpit as "Other Logs" and once you click to download it, the file name should be in the format of "application_<PID>_<date>.log"

    (6) Session ID and User Principal information can be retrieved either via javax.servlet.http.HttpServletRequest or java.security.Principal - so you need to capture that info before writing it to the log file.

    I have modified my spring boot logger app to include Spring Security (very basic) so I could capture the user details and the session id onto the logs.

    Regards,
    Ivan

    Add comment
    10|10000 characters needed characters exceeded

    • Big thanks, it is actual for me again because the last possibility to track log was disabled, I have been using column "tenant" for passing there my data but know it looks it also was disabled

  • Mar 19 at 04:01 PM

    Hi Nikolay,

    Do you have SCP SDK installed on your Eclipse together with the Eclipse Plugins from SAP? If so, you are able to test your Java application locally, using the same runtime as you would find on SCP (i.e.: Tomcat 8 runtime). With that in mind, you can configure the logging via the runtime server you assign your application in Eclipse. Just double-click on the server configuration from the servers view and select the Loggers tab. Please take a look at mine:

    Here I have set my package to be logging DEBUG information. Notice that the server configuration is local, so once you save it, it will be stored on the logging.properties file located on the "servers" folder of your eclipse as a "project". Please note that the loggers will only be displayed whenever your server is started. So add you application to the server and start it before trying to configure anything.

    Once you are satisfied with the config, you can use the logging properties file on SCP.

    To be able to log messages on the default trace files you can stick with slf4j log factory, just like this:

    Log messages will appear like this:

    Regards,
    Ivan

    Add comment
    10|10000 characters needed characters exceeded