Open dipakkumar1225 opened 11 months ago
@dipakkumar1225 check "Logs" folder is created or not (System.getProperty("user.dir") + File.separator + "Logs" + File.separator + "Server.logs")). If not create the Logs folder and try!!
@dipakkumar1225 check "Logs" folder is created or not (System.getProperty("user.dir") + File.separator + "Logs" + File.separator + "Server.logs")). If not create the Logs folder and try!!
@ashwithpoojary98 Folder and files both are present.
For safety, I am checking the folder present or not, But still getting same error
private static AppiumDriverLocalService getAppiumDriverService() {
File logDir = new File(System.getProperty("user.dir") + File.separator + "Logs");
if (!logDir.exists()) {
logDir.mkdirs();
}
return AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.withIPAddress("127.0.0.1")
.usingPort(DEFAULT_APPIUM_SERVER_PORT)
.withArgument(GeneralServerFlag.BASEPATH, "/wd/hub/")
.withArgument(GeneralServerFlag.LOG_LEVEL, "info:debug")
.withArgument(GeneralServerFlag.USE_DRIVERS, "UiAutomator2")
.withArgument(GeneralServerFlag.ALLOW_INSECURE, "adb_shell")
.withArgument(GeneralServerFlag.RELAXED_SECURITY)
.withArgument(GeneralServerFlag.USE_PLUGINS, "images")
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
.withLogFile(new File(System.getProperty("user.dir") + File.separator + "Logs" + File.separator + "Server.logs")));
}
please try below code,
File logDir = new File(System.getProperty("user.dir") + File.separator + "Logs"); if (!logDir.exists()) { logDir.mkdirs(); }
return AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.withIPAddress("127.0.0.1")
.usingPort(DEFAULT_APPIUM_SERVER_PORT)
.withArgument(GeneralServerFlag.BASEPATH, "/wd/hub/")
.withArgument(GeneralServerFlag.LOG_LEVEL, "info:debug")
.withArgument(GeneralServerFlag.USE_DRIVERS, "UiAutomator2")
.withArgument(GeneralServerFlag.ALLOW_INSECURE, "adb_shell")
.withArgument(GeneralServerFlag.RELAXED_SECURITY)
.withArgument(GeneralServerFlag.USE_PLUGINS, "images")
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
.withLogFile(logDir+ "Server.logs"));
}
please try below code,
File logDir = new File(System.getProperty("user.dir") + File.separator + "Logs"); if (!logDir.exists()) { logDir.mkdirs(); }
return AppiumDriverLocalService.buildService(new AppiumServiceBuilder() .withIPAddress("127.0.0.1") .usingPort(DEFAULT_APPIUM_SERVER_PORT) .withArgument(GeneralServerFlag.BASEPATH, "/wd/hub/") .withArgument(GeneralServerFlag.LOG_LEVEL, "info:debug") .withArgument(GeneralServerFlag.USE_DRIVERS, "UiAutomator2") .withArgument(GeneralServerFlag.ALLOW_INSECURE, "adb_shell") .withArgument(GeneralServerFlag.RELAXED_SECURITY) .withArgument(GeneralServerFlag.USE_PLUGINS, "images") .withArgument(GeneralServerFlag.SESSION_OVERRIDE) .withLogFile(logDir+ "Server.logs"));
}
I tried this too, but still getting same error.
private static AppiumDriverLocalService getAppiumDriverService() {
File logDir = new File(System.getProperty("user.dir") + File.separator + "Logs");
if (!logDir.exists()) {
logDir.mkdirs();
}
File serverLogsFile = new File(logDir, "Servers.logs");
if (!serverLogsFile.exists()) {
try {
serverLogsFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
return AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.withIPAddress("127.0.0.1")
.usingPort(DEFAULT_APPIUM_SERVER_PORT)
.withLogFile(serverLogsFile)
.withArgument(GeneralServerFlag.BASEPATH, "/wd/hub/")
.withArgument(GeneralServerFlag.LOG_LEVEL, "info:debug")
.withArgument(GeneralServerFlag.USE_DRIVERS, "UiAutomator2")
.withArgument(GeneralServerFlag.ALLOW_INSECURE, "adb_shell")
.withArgument(GeneralServerFlag.RELAXED_SECURITY)
.withArgument(GeneralServerFlag.USE_PLUGINS, "images")
.withArgument(GeneralServerFlag.SESSION_OVERRIDE));
}
File serverLogsFile = new File(logDir, "Servers.logs"); if (!serverLogsFile.exists()) { try { serverLogsFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } don't create a log file directly use it!!
return AppiumDriverLocalService.buildService(new AppiumServiceBuilder() .withIPAddress("127.0.0.1") .usingPort(DEFAULT_APPIUM_SERVER_PORT) .withArgument(GeneralServerFlag.BASEPATH, "/wd/hub/") .withArgument(GeneralServerFlag.LOG_LEVEL, "info:debug") .withArgument(GeneralServerFlag.USE_DRIVERS, "UiAutomator2") .withArgument(GeneralServerFlag.ALLOW_INSECURE, "adb_shell") .withArgument(GeneralServerFlag.RELAXED_SECURITY) .withArgument(GeneralServerFlag.USE_PLUGINS, "images") .withArgument(GeneralServerFlag.SESSION_OVERRIDE) .withLogFile(logDir+ "Server.logs"));
File serverLogsFile = new File(logDir, "Servers.logs"); if (!serverLogsFile.exists()) { try { serverLogsFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } don't create a log file directly use it!!
return AppiumDriverLocalService.buildService(new AppiumServiceBuilder() .withIPAddress("127.0.0.1") .usingPort(DEFAULT_APPIUM_SERVER_PORT) .withArgument(GeneralServerFlag.BASEPATH, "/wd/hub/") .withArgument(GeneralServerFlag.LOG_LEVEL, "info:debug") .withArgument(GeneralServerFlag.USE_DRIVERS, "UiAutomator2") .withArgument(GeneralServerFlag.ALLOW_INSECURE, "adb_shell") .withArgument(GeneralServerFlag.RELAXED_SECURITY) .withArgument(GeneralServerFlag.USE_PLUGINS, "images") .withArgument(GeneralServerFlag.SESSION_OVERRIDE) .withLogFile(logDir+ "Server.logs"));
This also not working. Please explain "don't create a log file directly use it!!" .withLogFile()); this accept File as a parameter
@mykola-mokhnach Can you please guide me on this?
Today I tried by simply creating Java application and with these too getting the same error.
public static void main(String[] args) {
AppiumDriverLocalService appiumDriverLocalService = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.withIPAddress("127.0.0.1")
.usingPort(4723)
.withArgument(GeneralServerFlag.BASEPATH, "/wd/hub/")
.withArgument(GeneralServerFlag.LOG_LEVEL, "info:debug")
.withLogFile(new File("Logs" + File.separator + "Server.log")));
appiumDriverLocalService.start();
appiumDriverLocalService.stop();
}
<dependencies>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>8.5.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>15</source>
<target>15</target>
</configuration>
</plugin>
</plugins>
</build>
Error:
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
Tried to attach logging to file 'D:\Automation-Framework\Trial\Logs\Server.log' but an error occurred: EBUSY: resource busy or locked, unlink 'D:\Automation-Framework\Trial\Logs\Server.log'
[Appium] Welcome to Appium v2.1.3
[Appium] Non-default server args:
[Appium] { address: '127.0.0.1', basePath: '/wd/hub/', loglevel: 'info:debug' }
[Appium] Attempting to load driver uiautomator2...
[Appium] Attempting to load driver espresso...
[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
[Appium] - element-wait@2.0.3
[Appium] - gestures@3.0.0
[Appium] - appium-dashboard@v2.0.2
[Appium] No plugins activated. Use the --use-plugins flag with names of plugins to activate
[HTTP] --> GET /wd/hub/status
[HTTP] {}
[HTTP] <-- GET /wd/hub/status 200 6 ms - 110
[HTTP]
File serverLogsFile = new File(logDir, "Servers.logs"); if (!serverLogsFile.exists()) { try { serverLogsFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } don't create a log file directly use it!! return AppiumDriverLocalService.buildService(new AppiumServiceBuilder() .withIPAddress("127.0.0.1") .usingPort(DEFAULT_APPIUM_SERVER_PORT) .withArgument(GeneralServerFlag.BASEPATH, "/wd/hub/") .withArgument(GeneralServerFlag.LOG_LEVEL, "info:debug") .withArgument(GeneralServerFlag.USE_DRIVERS, "UiAutomator2") .withArgument(GeneralServerFlag.ALLOW_INSECURE, "adb_shell") .withArgument(GeneralServerFlag.RELAXED_SECURITY) .withArgument(GeneralServerFlag.USE_PLUGINS, "images") .withArgument(GeneralServerFlag.SESSION_OVERRIDE) .withLogFile(logDir+ "Server.logs"));
This also not working. Please explain "don't create a log file directly use it!!" .withLogFile()); this accept File as a parameter
@dipakkumar1225 I'm not sure what the exact issue is, but the error clearly says that the file write operation is not allowed. Try renaming the project folder, "D:\Automation-Framework", to "AutomationFramework" (without the special character).
File serverLogsFile = new File(logDir, "Servers.logs"); if (!serverLogsFile.exists()) { try { serverLogsFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } don't create a log file directly use it!! return AppiumDriverLocalService.buildService(new AppiumServiceBuilder() .withIPAddress("127.0.0.1") .usingPort(DEFAULT_APPIUM_SERVER_PORT) .withArgument(GeneralServerFlag.BASEPATH, "/wd/hub/") .withArgument(GeneralServerFlag.LOG_LEVEL, "info:debug") .withArgument(GeneralServerFlag.USE_DRIVERS, "UiAutomator2") .withArgument(GeneralServerFlag.ALLOW_INSECURE, "adb_shell") .withArgument(GeneralServerFlag.RELAXED_SECURITY) .withArgument(GeneralServerFlag.USE_PLUGINS, "images") .withArgument(GeneralServerFlag.SESSION_OVERRIDE) .withLogFile(logDir+ "Server.logs"));
This also not working. Please explain "don't create a log file directly use it!!" .withLogFile()); this accept File as a parameter
@dipakkumar1225 I'm not sure what the exact issue is, but the error clearly says that the file write operation is not allowed. Try renaming the project folder, "D:\Automation-Framework", to "AutomationFramework" (without the special character).
@ashwithpoojary98
Tried the suggested approach still the same error
Tried to attach logging to file 'D:\Trial\Logs\Server.log' but an error occurred: EBUSY: resource busy or locked, unlink 'D:\Trial\Logs\Server.log'
[Appium] Welcome to Appium v2.1.3
[Appium] Non-default server args:
[Appium] { address: '127.0.0.1', basePath: '/wd/hub/', loglevel: 'info:debug' }
[Appium] Attempting to load driver uiautomator2...
[Appium] Attempting to load driver espresso...
[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
[Appium] - element-wait@2.0.3
[Appium] - gestures@3.0.0
[Appium] - appium-dashboard@v2.0.2
[Appium] No plugins activated. Use the --use-plugins flag with names of plugins to activate
[HTTP] --> GET /wd/hub/status
[HTTP] {}
[HTTP] <-- GET /wd/hub/status 200 9 ms - 110
[HTTP]
Process finished with exit code 0
@ashwithpoojary98 @mykola-mokhnach
Today, I tested by downgrading the Selenium version to 4.12.0, and logs attached successfully to file. Additionally, if the "Logs" folder is not present, it gets created at runtime. But if I change the selenium version 4.12.0 onwards then started getting issue EBUSY: resource busy or locked
<dependencies>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>8.6.0</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
</exclusion>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-http</artifactId>
</exclusion>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-json</artifactId>
</exclusion>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-manager</artifactId>
</exclusion>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-os</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.12.0</version>
</dependency>
</dependencies>
Logs
[Appium] Welcome to Appium v2.1.3
[Appium] Non-default server args:
[Appium] { address: '127.0.0.1', basePath: '/wd/hub/', loglevel: 'info:debug' }
[Appium] Attempting to load driver uiautomator2...
[Appium] Attempting to load driver espresso...
[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
[Appium] - element-wait@2.0.3
[Appium] - gestures@3.0.0
[Appium] - appium-dashboard@v2.0.2
[Appium] No plugins activated. Use the --use-plugins flag with names of plugins to activate
[HTTP] --> GET /wd/hub/status
[HTTP] {}
[HTTP] <-- GET /wd/hub/status 200 8 ms - 110
[HTTP]
Process finished with exit code 0
Any change this issue has been looked into?
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
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 ]
Appium Server Log: