appium / appium/java-client

EBUSY: resource busy or locked; Not able to attach log to file

Open
#2,021 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.3k
Forks
752
Avg merge
6d 21h
Merged PRs (30d)
8

Description

Description

Getting below issue:

Tried to attach logging to file 'D:\Automation-Framework\Generic\generic\Logs\Server.logs' but an error occurred: EBUSY: resource busy or locked, unlink 'D:\Automation-Framework\Generic\generic\Logs\Server.logs'

Environment

  • Java client build version or git revision if you use some snapshot: 8.5.1
  • Appium server version or git revision if you use some snapshot: 2.1.3
  • Desktop OS/version used to run Appium if necessary: Windows 10
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: v18.18.0
  • Mobile platform/version under test: Android
  • Real device or emulator/simulator:

Details

I am starting and stopping the Appium server programmatically and this is working properly. The Appium logs displayed properly in console. but when tried to capture this log into file as that time I am getting error EBUSY: resource busy or locked. Folder Logs and file Server.logs is present.

Code To Reproduce Issue [ Good To Have ]

private AppiumDriverLocalService getAppiumDriverService() {
        return AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
                .withIPAddress("127.0.0.1")
                .usingPort(DEFAULT_APPIUM_SERVER_PORT)
                .withArgument(GeneralServerFlag.BASEPATH, "/wd/hub/")
                .withArgument(GeneralServerFlag.USE_DRIVERS, "UiAutomator2")
                .withArgument(GeneralServerFlag.ALLOW_INSECURE, "adb_shell")
                .withArgument(GeneralServerFlag.RELAXED_SECURITY)
                .withArgument(GeneralServerFlag.USE_PLUGINS, "images")
                .withArgument(GeneralServerFlag.SESSION_OVERRIDE)
                .withArgument(GeneralServerFlag.LOG_LEVEL, "info")
                .withLogFile(new File(System.getProperty("user.dir") + File.separator + "Logs" + File.separator + "Server.logs")));
    }

Appium Server Log:

Tried to attach logging to file 'D:\Automation-Framework\Generic\generic\Logs\Server.logs' but an error occurred: EBUSY: resource busy or locked, unlink 'D:\Automation-Framework\Generic\generic\Logs\Server.logs'
[Appium] Attempting to load plugin images...
[Appium] Welcome to Appium v2.1.3
[Appium] Non-default server args:
[Appium] { address: '127.0.0.1',
[Appium]   allowInsecure: [ 'adb_shell' ],
[Appium]   basePath: '/wd/hub/',
[Appium]   loglevel: 'info',
[Appium]   relaxedSecurityEnabled: true,
[Appium]   sessionOverride: true,
[Appium]   useDrivers: [ 'UiAutomator2' ],
[Appium]   usePlugins: [ 'images' ] }
[Appium] Appium REST http interface listener started on http://127.0.0.1:4723/wd/hub
[Appium] Available drivers:
[Appium]   - uiautomator2@2.29.9 (automationName 'UiAutomator2')
[Appium]   - espresso@2.25.7 (automationName 'Espresso')
[Appium] Available plugins:
[Appium]   - images@2.1.4 (ACTIVE)
[Appium]   - element-wait@2.0.3
[HTTP] --> GET /wd/hub/status
[HTTP] {}
[AppiumDriver@19a4] Plugins which can handle cmd 'getStatus': images
[AppiumDriver@19a4] Plugin images is now handling cmd 'getStatus'
[AppiumDriver@19a4] Executing default handling behavior for command 'getStatus'
APPIUM SERVER STARTED
[HTTP] <-- GET /wd/hub/status 200 6 ms - 110
[HTTP] 

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at AppiumDriverLocalService.buildService and AppiumServiceBuilder.withLogFile, then reproduce the programmatic start/stop flow on Windows 10 with the existing Server.logs file. Trace how the service handles the log path during startup and shutdown. Done means repeated service startup no longer reports EBUSY while log output remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.