1818
1919import  java .io .Console ;
2020import  java .nio .charset .Charset ;
21+ import  java .nio .charset .StandardCharsets ;
2122import  java .util .function .BiConsumer ;
2223import  java .util .function .Function ;
2324
@@ -95,10 +96,6 @@ protected Console getConsole() {
9596		return  System .console ();
9697	}
9798
98- 	protected  Charset  getDefaultCharset () {
99- 		return  Charset .defaultCharset ();
100- 	}
101- 
10299	public  final  void  apply () {
103100		apply (null );
104101	}
@@ -120,11 +117,14 @@ private PropertyResolver getPropertyResolver() {
120117	}
121118
122119	protected  void  apply (LogFile  logFile , PropertyResolver  resolver ) {
120+ 		Charset  defaultCharset  = getDefaultCharset ();
121+ 		Charset  consoleCharset  = (defaultCharset  != null ) ? defaultCharset  : getDefaultConsoleCharset ();
122+ 		Charset  fileCharset  = (defaultCharset  != null ) ? defaultCharset  : getDefaultFileCharset ();
123123		setSystemProperty (LoggingSystemProperty .APPLICATION_NAME , resolver );
124124		setSystemProperty (LoggingSystemProperty .APPLICATION_GROUP , resolver );
125125		setSystemProperty (LoggingSystemProperty .PID , new  ApplicationPid ().toString ());
126- 		setSystemProperty (LoggingSystemProperty .CONSOLE_CHARSET , resolver , getConsoleCharset () .name ());
127- 		setSystemProperty (LoggingSystemProperty .FILE_CHARSET , resolver , getDefaultCharset () .name ());
126+ 		setSystemProperty (LoggingSystemProperty .CONSOLE_CHARSET , resolver , consoleCharset .name ());
127+ 		setSystemProperty (LoggingSystemProperty .FILE_CHARSET , resolver , fileCharset .name ());
128128		setSystemProperty (LoggingSystemProperty .CONSOLE_THRESHOLD , resolver , this ::thresholdMapper );
129129		setSystemProperty (LoggingSystemProperty .FILE_THRESHOLD , resolver , this ::thresholdMapper );
130130		setSystemProperty (LoggingSystemProperty .EXCEPTION_CONVERSION_WORD , resolver );
@@ -140,9 +140,32 @@ protected void apply(LogFile logFile, PropertyResolver resolver) {
140140		}
141141	}
142142
143- 	private  Charset  getConsoleCharset () {
143+ 	/** 
144+ 	 * Returns the default charset. 
145+ 	 * @return the default charset 
146+ 	 * @deprecated since 3.5.0 for removal in 3.7.0 in favor of 
147+ 	 * {@link #getDefaultConsoleCharset()} and {@link #getDefaultFileCharset()}. 
148+ 	 */ 
149+ 	@ Deprecated (since  = "3.5.0" , forRemoval  = true )
150+ 	protected  Charset  getDefaultCharset () {
151+ 		return  null ;
152+ 	}
153+ 
154+ 	/** 
155+ 	 * Returns the default console charset. 
156+ 	 * @return returns the default console charset 
157+ 	 */ 
158+ 	protected  Charset  getDefaultConsoleCharset () {
144159		Console  console  = getConsole ();
145- 		return  (console  != null ) ? console .charset () : getDefaultCharset ();
160+ 		return  (console  != null ) ? console .charset () : Charset .defaultCharset ();
161+ 	}
162+ 
163+ 	/** 
164+ 	 * Returns the default file charset. 
165+ 	 * @return returns the default file charset 
166+ 	 */ 
167+ 	protected  Charset  getDefaultFileCharset () {
168+ 		return  StandardCharsets .UTF_8 ;
146169	}
147170
148171	private  void  setSystemProperty (LoggingSystemProperty  property , PropertyResolver  resolver ) {
0 commit comments