java - Spring Boot: use several locale message.properties for logging depending on 'args' value -


i kind of new in spring boot. want setup spring boot aplication choose specific locale messages.properties file when specific arg used when starting program. these message.properties fields used log program events , sending out email reports customers.

the examples found suitable web applications. , couldn't find suitable examples on how can achieved using inbuilt spring boot technology.

well, regular spring boot application run main() method - can set default locale via locale.setdefault method before run spring application, so:

@springbootapplication public class demoapplication {    public static void main(string[] args) {     locale defaultlocale = determinelocalefrom(args);     locale.setdefault(defaultlocale);      applicationcontext context = springapplication.run(demoapplication.class, args);      messagesource messagesource = context.getbean(messagesource.class);     // when fetching messages, read default locale     messagesource.getmessage("my.message.code", null, locale.getdefault());   }  } 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -