Skip to content
Advertisement

How to make path location dynamic in xml

I have a logback.xml configured in a spring MVC + hibernate project, it is working fine on my local machine. the local machine has windows 10 OS installed.

I wish to run the code of production machine which has Linux installed.

What is want to know, is there a way to make LOG_PATH and LOG_ARCHIVE locations dynamic according to OS ? So that when the code is deployed on production machine I would not have to manually change the the path locations.

Any help is appreciated, Let me know if anything else is needed. Thank you in advance. ๐Ÿ˜€

JavaScript

Advertisement

Answer

You can create the logback file in an external location and pass it as a param while starting the app as shown below.

JavaScript

Adding the following configuration to the logback.xml will scan the file every 30 seconds for any changes. If a change is detected it will reconfigure the log settings.

JavaScript

Now if you want to change anything you can directly change it in logback.xml

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement