当System.out .print在Azure函数(Java)中将日语字符输出到标准输出时,这些字符在Application中会被混淆。
是否有一种方法可以在应用程序洞察中显示消息而不混淆字符?
JVM选项指定:
JAVA_OPTS -Dfile.code=utf-8
@FunctionName("HttpExample")
public HttpResponseMessage run(
@HttpTrigger(
name = "req",
methods = {HttpMethod.GET, HttpMethod.POST},
authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
final ExecutionContext context) {
context.getLogger().info("Java HTTP trigger processed a request.");
System.out.println("日本語表示");
// Parse query parameter
final String query = request.getQueryParameters().get("name");
final String name = request.getBody().orElse(query);
log.info("Get query : " + query);
log.info("Get name : " + name);
if (name == null) {
return request.createResponseBuilder(HttpStatus.BAD_REQUEST).body("Please pass a name on the query string or in the request body").build();
} else {
return request.createResponseBuilder(HttpStatus.OK).body("Hello, " + name).build();
}
}发布于 2021-03-12 04:25:39
是否有一种方法可以在应用程序洞察中显示消息而不混淆字符?
对于azure函数,打印输出时请不要使用System.out.println()打印信息。下面可以在应用程序洞察中显示消息,而不需要混淆字符:
String str = "日本語表示";
context.getLogger().info(str);

https://stackoverflow.com/questions/66548413
复制相似问题