Polish log4j2 sample
parent
c230a21a8c
commit
3ed5a723bb
@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2014 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package sample.actuator.log4j2;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class HelloWorldService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ServiceProperties configuration;
|
|
||||||
|
|
||||||
public String getHelloMessage() {
|
|
||||||
return "Hello " + this.configuration.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2016 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package sample.actuator.log4j2;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
public class SampleController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private HelloWorldService helloWorldService;
|
|
||||||
|
|
||||||
@GetMapping("/")
|
|
||||||
@ResponseBody
|
|
||||||
public Map<String, String> helloWorld() {
|
|
||||||
return Collections.singletonMap("message",
|
|
||||||
this.helloWorldService.getHelloMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping("/foo")
|
|
||||||
@ResponseBody
|
|
||||||
public String foo() {
|
|
||||||
throw new IllegalArgumentException("Server error");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2014 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package sample.actuator.log4j2;
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@ConfigurationProperties(prefix = "service", ignoreUnknownFields = false)
|
|
||||||
@Component
|
|
||||||
public class ServiceProperties {
|
|
||||||
|
|
||||||
private String name = "World";
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,18 +1,3 @@
|
|||||||
#logging.file=/tmp/logs/app.log
|
|
||||||
#server.port=8080
|
|
||||||
#management.port=8080
|
|
||||||
management.address=127.0.0.1
|
|
||||||
management.shell.ssh.enabled=true
|
|
||||||
management.shell.ssh.port=2222
|
|
||||||
#management.shell.telnet.enabled=false
|
|
||||||
#management.shell.telnet.port=1111
|
|
||||||
management.shell.auth.type=spring
|
|
||||||
#management.shell.auth.type=key
|
|
||||||
#management.shell.auth.key.path=${user.home}/test/id_rsa.pub.pem
|
|
||||||
#management.shell.auth.type=simple
|
|
||||||
|
|
||||||
endpoints.shutdown.enabled=true
|
endpoints.shutdown.enabled=true
|
||||||
server.tomcat.basedir=target/tomcat
|
|
||||||
server.tomcat.access_log_pattern=%h %t "%r" %s %b
|
management.security.enabled=false
|
||||||
security.require_ssl=false
|
|
||||||
service.name=Daniel
|
|
Loading…
Reference in New Issue