{"record":{"id":"a3717d00eb2c28c3","repo":"immich-app/immich","slug":"logging-cannot-be-changed-while-the-environment-va","errorCode":null,"errorMessage":"Logging cannot be changed while the environment variable IMMICH_LOG_LEVEL is set.","messagePattern":"Logging cannot be changed while the environment variable IMMICH_LOG_LEVEL is set\\.","errorType":"validation","errorClass":"Error","httpStatus":400,"severity":"error","filePath":"server/src/services/system-config.service.ts","lineNumber":80,"sourceCode":"    const configLevel = logging.enabled ? logging.level : false;\n    const level = envLevel ?? configLevel;\n    this.logger.setLogLevel(level);\n    this.logger.log(`LogLevel=${level} ${envLevel ? '(set via IMMICH_LOG_LEVEL)' : '(set via system config)'}`);\n\n    this.machineLearningRepository.setup(machineLearning);\n  }\n\n  @OnEvent({ name: 'ConfigUpdate', server: true })\n  onConfigUpdate({ newConfig }: ArgOf<'ConfigUpdate'>) {\n    this.onConfigInit({ newConfig });\n    clearConfigCache();\n  }\n\n  @OnEvent({ name: 'ConfigValidate' })\n  onConfigValidate({ newConfig, oldConfig }: ArgOf<'ConfigValidate'>) {\n    const { logLevel } = this.configRepository.getEnv();\n    if (logLevel && !isEqual(toPlainObject(newConfig.logging), oldConfig.logging)) {\n      throw new Error('Logging cannot be changed while the environment variable IMMICH_LOG_LEVEL is set.');\n    }\n  }\n\n  async updateAdminConfig(dto: AdminConfigDto): Promise<AdminConfigDto> {\n    const { configFile } = this.configRepository.getEnv();\n    if (configFile) {\n      throw new BadRequestException('Cannot update configuration while IMMICH_CONFIG_FILE is in use');\n    }\n\n    const oldConfig = await this.getConfig({ withCache: false });\n\n    try {\n      await this.eventRepository.emit('ConfigValidate', { newConfig: toPlainObject(dto), oldConfig });\n    } catch (error) {\n      this.logger.warn(`Unable to save system config due to a validation error: ${error}`);\n      throw new BadRequestException(error instanceof Error ? error.message : error);\n    }\n","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/server/src/services/system-config.service.ts#L62-L98","documentation":"When IMMICH_LOG_LEVEL is set via environment, it takes precedence over the admin UI logging settings. onConfigValidate throws if a config save would change logging settings, because the change would be silently ignored or cause conflicting behavior.","triggerScenarios":"IMMICH_LOG_LEVEL env var is set AND an admin submits a system config whose logging section differs from the old config (e.g. changing log level in the admin UI).","commonSituations":"Admin tries to change log level from the web UI while the docker-compose file pins IMMICH_LOG_LEVEL; mixed env-var + database config.","solutions":["Remove the IMMICH_LOG_LEVEL environment variable and restart, then change logging via the admin UI","Keep IMMICH_LOG_LEVEL set and leave the logging section of the admin config unchanged","Resubmit the config without modifying the logging section"],"exampleFix":"// before\nenvironment:\n  IMMICH_LOG_LEVEL: verbose\n// admin UI changes logging level -> error\n// after\nenvironment: {}\n// then change log level in the admin UI","handlingStrategy":"validation","validationCode":"if (process.env.IMMICH_LOG_LEVEL) {\n  assert.deepStrictEqual(toPlainObject(newConfig.logging), oldConfig.logging,\n    'Logging section must stay unchanged while IMMICH_LOG_LEVEL is set');\n}","typeGuard":"null","tryCatchPattern":"try {\n  await saveAdminConfig(dto);\n} catch (e) {\n  if (e.status === 500 && e.message.includes('IMMICH_LOG_LEVEL')) {\n    dto = { ...dto, logging: oldLoggingSection }; // retry without logging change\n  }\n}","preventionTips":["Manage logging via ONE source: env var or admin UI, not both","Remove IMMICH_LOG_LEVEL if the UI should control log level","Diff config payloads against old config before saving"],"tags":["config","logging","env-var","conflict"],"backgroundTag":"conflicting-config-options","analyzedSha":"e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c","analyzedAt":"2026-09-15T07:20:19.675Z","contentChangedAt":"2026-09-15T07:20:19.675Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}