Home > other >  ERROR: org.apache.logging.log4j.Logger.atDebug()Lorg/apache/logging/log4j/LogBuilder
ERROR: org.apache.logging.log4j.Logger.atDebug()Lorg/apache/logging/log4j/LogBuilder

Time:07-20

When I try import a file from front to my api, throws this error: org.apache.logging.log4j.Logger.atDebug()Lorg/apache/logging/log4j/LogBuilder

I just have this log4j dependency in my pom.xml:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.25</version>
    </dependency>

This is my Controller:

@RestController
@RequestMapping(value = "/api/importacao", produces = { "application/json" })
@CrossOrigin("*")
public class ImportacaoController {

    @Autowired
    private VeiculoService veiculoService;

    @Autowired
    private ImportacaoService importService;

    @PostMapping("/uploadexcel")
    public ResponseEntity<String> salvarArquivo(@RequestParam("file") MultipartFile file) {
        String caminho = UUID.randomUUID()   "."   extrairExtensao(file.getOriginalFilename());

        try {
            List<Veiculo> veiculos = veiculoService.converteArquivo(file);
            veiculos = veiculoService.salvarVeiculos(veiculos);
            Files.copy(file.getInputStream(), Paths.get(caminho), StandardCopyOption.REPLACE_EXISTING);

            Importacao importacao = new Importacao(caminho, LocalDate.now());
            importacao = importService.salvarImportacao(importacao);
            return new ResponseEntity<>("{\"Arquivo carregado com sucesso!\"}", HttpStatus.OK);
        } catch (Exception e) {
            return new ResponseEntity<>("{\"Erro ao carregar o arquivo!\"}",
                    HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }

private String extrairExtensao(String nomeArquivo) {
    int i = nomeArquivo.lastIndexOf(".");
    return nomeArquivo.substring(i   1);
}

Thank you in advance.

CodePudding user response:

I saw a post that solved my problem, just put this dependency:

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-to-slf4j</artifactId>
            <version>2.17.2</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.17.2</version>
        </dependency>
  • Related