스프링 프로젝트를 세팅하고 서버 실행해서 확인해보는데 로그가 찍히지 않아서 이유를 열심히 찾아보았다
코드
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Controller
@RequestMapping("testtt")
public class TestController {
@GetMapping("name")
public String name() {
log.debug("로그로그");
return "dd";
}
}
에러
com.sun.org.apache.xerces.internal.util.URI$MalformedURIException: Path contains invalid character: 이 at com.sun.org.apache.xerces.internal.util.URI.initializePath(URI.java:1110) at com.sun.org.apache.xerces.internal.util.URI.initialize(URI.java:583) at com.sun.org.apache.xerces.internal.util.URI.<init>(URI.java:336) at com.sun.org.apache.xerces.internal.util.URI.<init>(URI.java:299) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.expandSystemIdStrictOff1(XMLEntityManager.java:2285) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.expandSystemId(XMLEntityManager.java:2117) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntityAsPerStax(XMLEntityManager.java:966) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1179) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1073) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:974) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:507) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:867) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:796) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:142) at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:247) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:177) at org.apache.log4j.xml.DOMConfigurator$2.parse(DOMConfigurator.java:690) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:789) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:696) at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:471) at org.apache.log4j.LogManager.<clinit>(LogManager.java:125) at org.slf4j.reload4j.Reload4jLoggerFactory.<init>(Reload4jLoggerFactory.java:66) at org.slf4j.reload4j.Reload4jServiceProvider.initialize(Reload4jServiceProvider.java:35) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:183) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:170) at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:455) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:441) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:390) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4007) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4448) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:721) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:211) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:415) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:878) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) at org.apache.catalina.startup.Catalina.start(Catalina.java:735) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473)
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system properly. 9월 05, 2024 6:35:54 오후 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom 경고: [SHA1PRNG] 알고리즘을 사용하여, 세션 ID를 생성하기 위한 SecureRandom 객체를 생성하는데, [865] 밀리초가 소요됐습니다. 9월 05, 2024 6:35:54 오후 org.apache.catalina.core.ApplicationContext log 정보: Initializing Spring DispatcherServlet 'appServlet' 9월 05, 2024 6:36:02 오후 org.apache.coyote.AbstractProtocol start 정보: 프로토콜 핸들러 ["http-nio-80"]을(를) 시작합니다. 9월 05, 2024 6:36:02 오후 org.apache.catalina.startup.Catalina start 정보: 서버가 [34828] 밀리초 내에 시작되었습니다.
해결
log4j 버전도 바꿔보고 lombok도 다시 설치하고 다 해봤지만 이유는 간단했다
워크스페이스가 사용자이름 하위에 있어서 경로에 한글이 포함된 것이었다
c드라이브 바로 밑으로 옮겨주었더니 문제가 해결되었다
로그가 나오지 않는 다양한 이유가 있겠지만 에러메시지에 이상하게 한글이 한개 보인다면 이 방법을 사용해보자!